X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=files%2Fetc%2Fpuppet%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fnodeinfo.rb;h=2e0521d191c6367069932a667dc2456656f639f8;hb=8bdab078f1596badc3ea821351068043f5485ae2;hp=84e5bc9960b8c96bf95fd62a25357805203fb627;hpb=594431cf80a3a56cda904228f36bd236d9606ab5;p=mirror%2Fdsa-puppet.git diff --git a/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb index 84e5bc996..2e0521d19 100644 --- a/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb +++ b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb @@ -5,8 +5,8 @@ module Puppet::Parser::Functions yamlfile = args[1] parser.watch_file(yamlfile) - require 'ldap' require 'yaml' + require '/etc/puppet/lib/puppet/parser/functions/ldapinfo.rb' $KCODE = 'utf-8' @@ -22,10 +22,9 @@ module Puppet::Parser::Functions end if yaml.has_key?('services') - ['bugsmaster', 'qamaster', 'mailrelay', 'rtmaster', 'packagesmaster'].each do |service| - if yaml['services'].has_key?(service) - results[service] = host == yaml['services'][service] - end + yaml['services'].each_pair do |service, hostlist| + hostlist=[hostlist] unless hostlist.kind_of?(Array) + results[service] = hostlist.include?(host) end end @@ -35,35 +34,20 @@ module Puppet::Parser::Functions results['smarthost_port'] = 587 results['reservedaddrs'] = '0.0.0.0/8 : 127.0.0.0/8 : 10.0.0.0/8 : 169.254.0.0/16 : 172.16.0.0/12 : 192.0.0.0/17 : 192.168.0.0/16 : 224.0.0.0/4 : 240.0.0.0/5 : 248.0.0.0/5' - if yaml.has_key?('mail_port') and yaml['mail_port'].has_key?(host) - results['mail_port'] = yaml['mail_port'][host] - end - - if yaml.has_key?('need_smarthost') and yaml['need_smarthost'].include?(host) - results['smarthost'] = "mailout.debian.org" - end - - if yaml.has_key?('reservedaddrs') and yaml['reservedaddrs'].has_key?(host) - results['reservedaddrs'] = yaml['reservedaddrs'][host] - end - - if yaml.has_key?('heavy_exim') and yaml['heavy_exim'].include?(host) - results['heavy_exim'] = "true" + if yaml['host_settings'].kind_of?(Hash) + yaml['host_settings'].each_pair do |property, values| + if values.kind_of?(Hash) + results[property] = values[host] if values.has_key?(host) + elsif values.kind_of?(Array) + results[property] = "true" if values.include?(host) + end + end end - ldap = LDAP::Conn.new('db.debian.org') - results['ldap'] = [] - filter = '(hostname=' + host +')' - begin - ldap.search2('ou=hosts,dc=debian,dc=org', LDAP::LDAP_SCOPE_SUBTREE, filter) do |x| - results['ldap'] << x - end - rescue LDAP::ResultError - rescue RuntimeError - ensure - ldap.unbind - end + results['ldap'] << function_ldapinfo(host, '*') return(results) end end + +# vim: set fdm=marker ts=2 sw=2 et: