X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=files%2Fetc%2Fpuppet%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fnodeinfo.rb;h=4d915b21bf05e486848d5d1da08eff889be2468b;hb=483f9c11e2419da2aa3fe83f306a2adf5f6938ef;hp=91255b218d2399721c2b57ede5c097a4af37b752;hpb=e47ce1f1dcdac0f11cae0aff10e79ca64589ed37;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 91255b218..4d915b21b 100644 --- a/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb +++ b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb @@ -3,60 +3,13 @@ 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' - - yaml = YAML.load_file(yamlfile) - results = {} - - ['nameinfo', 'footer'].each do |detail| - if yaml.has_key?(detail) - if yaml[detail].has_key?(host) - results[detail] = yaml[detail][host] - end - end - 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 - end - end - - if yaml.has_key?('need_smarthost') and yaml['need_smarthost'].include?(host) - results['smarthost'] = "mailout.debian.org" - results['smarthost_port'] = 587 - else - results['smarthost'] = '' - results['smarthost_port'] = '' - end - - results['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 + results = function_yamlinfo(host, yamlfile) + results['ldap'] = function_ldapinfo(host, '*') return(results) end end + +# vim: set fdm=marker ts=2 sw=2 et: