[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

James Turnbull james at lovedthanlost.net
Tue Oct 27 17:05:58 UTC 2009


The following commit has been merged in the upstream branch:
commit b0518c3938be6cef34eafeb0460116d98b2a64ca
Author: Markus Roberts <Markus at reality.com>
Date:   Wed Sep 30 15:00:19 2009 -0700

    Fix for #2681 (duplicate resource)
    
    Refactor to not generate explicit resources and to not bail out if
    one of a set can not be ensured absend.
    
    Signed-off-by: Markus Roberts <Markus at reality.com>

diff --git a/lib/puppet/type/resources.rb b/lib/puppet/type/resources.rb
index ab564a1..87bde97 100644
--- a/lib/puppet/type/resources.rb
+++ b/lib/puppet/type/resources.rb
@@ -85,33 +85,33 @@ Puppet::Type.newtype(:resources) do
         end
     end
 
+    def able_to_ensure_absent?(resource)
+        begin
+            resource[:ensure] = :absent
+        rescue ArgumentError, Puppet::Error => detail
+            err "The 'ensure' attribute on #{self[:name]} resources does not accept 'absent' as a value"
+            false
+        end
+    end
+
     # Generate any new resources we need to manage.  This is pretty hackish
     # right now, because it only supports purging.
     def generate
         return [] unless self.purge?
-        hascheck = false
-        method =
-        resource_type.instances.find_all do |resource|
-            ! resource.managed?
-        end.find_all do |resource|
-            check(resource)
-        end.each do |resource|
-            begin
-                resource[:ensure] = :absent
-            rescue ArgumentError, Puppet::Error => detail
-                err "The 'ensure' attribute on %s resources does not accept 'absent' as a value" %
-                    [self[:name]]
-                return []
-            end
+        resource_type.instances.
+          reject { |r| managed? }.
+          reject { |r| catalog.resources.include? r.ref }.
+          select { |r| check(r) }.
+          select { |r| able_to_ensure_absent?(r) }.
+          each { |resource|
             @parameters.each do |name, param|
-                next unless param.metaparam?
-                resource[name] = param.value
+                resource[name] = param.value if param.metaparam?
             end
 
             # Mark that we're purging, so transactions can handle relationships
             # correctly
             resource.purging
-        end
+          }
     end
 
     def resource_type

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list