summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMatt Robinson <matt@puppetlabs.com>2011-02-01 15:30:28 -0800
committerMatt Robinson <matt@puppetlabs.com>2011-02-01 15:30:28 -0800
commitfd73874147a1aaa3a047f904a0bc1ae67780a2e4 (patch)
tree3a987a1d31fedeb1efc04b19df63b0e85a299002 /lib
parentf135a6436084629d47c6b3b590dadb14952e4d69 (diff)
downloadpuppet-fd73874147a1aaa3a047f904a0bc1ae67780a2e4.tar.gz
puppet-fd73874147a1aaa3a047f904a0bc1ae67780a2e4.tar.xz
puppet-fd73874147a1aaa3a047f904a0bc1ae67780a2e4.zip
(#6107) Fix an error when auditing a file with empty content
The manifest: file { "/tmp/foo" : ensure => present, audit => content, } produced the error: err: /Stage[main]//File[/tmp/foo]/ensure: change from absent to present failed: Could not retrieve content for from filebucket: private method `sub' called for nil:NilClass at /Users/matthewrobinson/work/puppet/test.pp:4 This was due to logic in content assuming that if you didn't specify content while you were auditing it you must have specified a source. The code paths in the file type badly need a cleanup so that these sorts of errors aren't so difficult to track down and things are easier to test. Paired-with: Daniel Pittman
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/file/content.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/puppet/type/file/content.rb b/lib/puppet/type/file/content.rb
index 04b917a7e..cf924f371 100755
--- a/lib/puppet/type/file/content.rb
+++ b/lib/puppet/type/file/content.rb
@@ -167,6 +167,8 @@ module Puppet
def each_chunk_from(source_or_content)
if source_or_content.is_a?(String)
yield source_or_content
+ elsif source_or_content.nil? && resource.parameter(:ensure) && [:present, :file].include?(resource.parameter(:ensure).value)
+ yield ''
elsif source_or_content.nil?
yield read_file_from_filebucket
elsif self.class.standalone?