]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - files/etc/puppet/lib/puppet/parser/functions/allnodeinfo.rb
use weaselism: it has the benefit of possibly working
[dsa-puppet.git] / files / etc / puppet / lib / puppet / parser / functions / allnodeinfo.rb
index 3eab872d10187862f8d946d19cb6fdebf88eed50..922f604225b71d89b3f568f10ff853c2e8a10016 100644 (file)
@@ -10,11 +10,10 @@ module Puppet::Parser::Functions
     results = []
     filter = '(hostname=*)'
     begin
-      ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, filter, attrs=attributes, false, 0, 0, s_attr="hostname") do |x|
+      ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, filter, attrs=attributes, false, 0, 0, s_attr="hostname").each do |x|
         # If a returned value doesn't have all the attributes we're searching for, skip
-        attributes.each do |a|
-          next if x[a].empty?
-        end
+        # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes
+        next if attributes.any?{ |a|  not x[a] or x[a].empty? }
         results << x
       end
     rescue LDAP::ResultError