X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=files%2Fetc%2Fpuppet%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fnodeinfo.rb;h=c946206a55d8cd2815a3797efd016234af8d5c6a;hb=5ca9e9a43ca1861539b4e6385e16090f9ede73f0;hp=aae67bce261d10f9906fa4aaf7dc40a037dc26b4;hpb=9de308f6133b7b68152cc854ba7444d930b84e3a;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 aae67bce2..c946206a5 100644 --- a/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb +++ b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb @@ -3,48 +3,20 @@ module Puppet::Parser::Functions host = args[0] yamlfile = args[1] - parser.watch_file(yamlfile) - require 'ldap' - require 'yaml' + require '/etc/puppet/lib/puppet/parser/functions/ldapinfo.rb' - $KCODE = 'utf-8' + results = function_yamlinfo(host, yamlfile) + results['ldap'] = function_ldapinfo(host, '*') - yaml = YAML.load_file(yamlfile) - results = {} + results['misc'] = {} + # find out if we are behind nat + v4addrs = $v4ips.split(',') + intersection = v4addrs & nodeinfo['ldap']['ipHostNumber'] + results['misc']['natted'] = intersection.empty? - ['nameinfo', 'footer'].each do |detail| - if yaml.has_key?(detail) - if yaml[detail].has_key?(host) - results[detail] = yaml[detail][host] - end - end - end - - results['bugsmaster'] = host == 'rietz.debian.org' - results['qamaster'] = host == 'merkel.debian.org' - results['mailrelay'] = host == 'spohr.debian.org' - results['rtmaster'] = host == 'spohr.debian.org' - results['packagesmaster'] = host == 'powell.debian.org' - -# nodeinfo['reservedaddrs'] = case host -# when "ball.debian.org": '0.0.0.0/8 : 127.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' -# else '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' -# 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 return(results) end end + +# vim: set fdm=marker ts=2 sw=2 et: