]> git.donarmstrong.com Git - dsa-puppet.git/blob - modules/puppetmaster/lib/puppet/parser/functions/allnodeinfo.rb
Yay, puppet limitations
[dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / allnodeinfo.rb
1 module Puppet::Parser::Functions
2   newfunction(:allnodeinfo, :type => :rvalue) do |args|
3     required = args.shift.split()
4     optional = args.shift.split()
5
6     allhosts = function_ldapinfo('*', required+optional )
7     res = {}
8     allhosts.each_pair do |hostname, host|
9         # If a returned value doesn't have all the attributes we're searching for, skip
10         # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes
11         next if required.any?{ |a| not host[a] or host[a].empty? }
12         res[hostname] = host
13     end
14
15     return res
16   end
17 end
18 # vim:set et:
19 # vim:set sts=2 ts=2:
20 # vim:set shiftwidth=2: