$localinfo = yamlinfo('*', "/etc/puppet/modules/debian-org/misc/local.yaml")
$nodeinfo = nodeinfo($fqdn, "/etc/puppet/modules/debian-org/misc/local.yaml")
$hosterinfo = whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
- $allnodeinfo = allnodeinfo("sshRSAHostKey", "ipHostNumber", "purpose")
+ $allnodeinfo = allnodeinfo(["sshRSAHostKey", "ipHostNumber"], ["purpose"])
$mxinfo = allnodeinfo("mXRecord")
notice("hoster for ${fqdn} is ${hosterinfo}")
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:
filter = '(hostname=' + host + ')'
begin
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
- # We'll skip if the array is empty, but we also seem to get back a nil object for empty attributes sometimes
- unless attributes.include?("*")
- next if attributes.any?{ |a| not x[a] or x[a].empty? }
- end
results[x['hostname'][0]] = x
end
rescue LDAP::ResultError