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.
Signed-off-by: Nick Lewis <[email protected]> --- lib/puppet/type/file.rb | 10 +++++++++- spec/unit/type/file.rb | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 0aaad3e..5bb4be1 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 206a50e..b2f1292 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) -- 1.7.1 -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
