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