X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;ds=sidebyside;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fallnodeinfo.rb;h=85a0c749b39c9b59957a6f298a7b5a2cf0153933;hb=fbdfced4d644a867a1913ff13e94fb6851bb8442;hp=47450d559e65f9ab7670febcdef26cf4b25114ed;hpb=3f18a1c4060aab4bc63c84fc805dc15a5ba6de9e;p=mirror%2Fdsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb b/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb index 47450d559..85a0c749b 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb @@ -1,6 +1,20 @@ module Puppet::Parser::Functions - newfunction(:allnodeinfo, :type => :rvalue) do |attributes| - attributes.unshift('*') - return (function_ldapinfo(attributes)) + newfunction(:allnodeinfo, :type => :rvalue) do |args| + required = args.shift + optional = args.shift + + allhosts = function_ldapinfo('*', required+optional ) + res = {} + allhosts.each_pair do |hostname, host| + # If a returned value doesn't have all the attributes we're searching for, skip + # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes + next if required.any?{ |a| not host[a] or host[a].empty? } + res[hostname] = host + end + + return res end end +# vim:set et: +# vim:set sts=2 ts=2: +# vim:set shiftwidth=2: