summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2010-06-17 17:49:29 -0700
committerJames Turnbull <james@lovedthanlost.net>2010-06-27 03:48:07 +1000
commit34d189725c82e221793dc51c04ecb68e43ed3115 (patch)
treef7940110616690ee8b05527c3988c4e2e96263aa
parent9d0d94c27174bc25ba823028a612f8fa04dd847b (diff)
downloadpuppet-34d189725c82e221793dc51c04ecb68e43ed3115.tar.gz
puppet-34d189725c82e221793dc51c04ecb68e43ed3115.tar.xz
puppet-34d189725c82e221793dc51c04ecb68e43ed3115.zip
[#3835] Fixed recursively absent directories improperly managing their files
Children of recursively absent (and only recursively absent) directories now inherit the recursively absent behavior when they are created. This stops the files from trying to be created, generating lots of failure messages. This doesn't affect directories which are absent and not recursive (whose children aren't even attempted to be created, or directories which aren't absent.
-rw-r--r--lib/puppet/type/file.rb10
-rwxr-xr-xspec/unit/type/file.rb8
2 files changed, 17 insertions, 1 deletions
diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb
index 0aaad3e97..5bb4be1e4 100644
--- a/lib/puppet/type/file.rb
+++ b/lib/puppet/type/file.rb
@@ -433,8 +433,16 @@ module Puppet
# The right-side hash wins in the merge.
options = @original_parameters.merge(:path => full_path).reject { |param, value| value.nil? }
+ # If we are recursive and ensure => absent, then our children should be too,
+ # so that they will go away like they should.
+ # Otherwise they shouldn't get those options
+ unless options[:ensure].to_s == "absent" and options[:recurse] == true
+ options.delete(:ensure)
+ options.delete(:recurse)
+ end
+
# These should never be passed to our children.
- [:parent, :ensure, :recurse, :recurselimit, :target, :alias, :source].each do |param|
+ [:parent, :recurselimit, :target, :alias, :source].each do |param|
options.delete(param) if options.include?(param)
end
diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb
index 206a50ed9..b2f12927f 100755
--- a/spec/unit/type/file.rb
+++ b/spec/unit/type/file.rb
@@ -694,6 +694,14 @@ describe Puppet::Type.type(:file) do
end
end
+ it "should pass on ensure and recurse to the sub resource if ensure is absent and recurse is true" do
+ @file = Puppet::Type::File.new(:name => "/foo/bar", :ensure => :absent, :recurse => true, :catalog => @catalog)
+
+ @file.class.expects(:new).with { |params| params[:ensure] == :absent and params[:recurse] == true }
+
+ @file.newchild("my/path")
+ end
+
it "should copy all of the parent resource's 'should' values that were set at initialization" do
file = @file.class.new(:path => "/foo/bar", :owner => "root", :group => "wheel")
@catalog.add_resource(file)