X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Fpuppetmaster%2Flib%2Fpuppet%2Fparser%2Ffunctions%2Fnodeinfo.rb;h=1380a02ed526a1135b32a39a2b9b4c45a8861fbf;hb=249b713a08d35bffb1cd52739be6f5808baa5a5f;hp=41a071afccd9e91d1b270b4d8a2526299bd66dc8;hpb=b0c0ca5a8846526179ff9566f248405be011ef62;p=mirror%2Fdsa-puppet.git diff --git a/modules/puppetmaster/lib/puppet/parser/functions/nodeinfo.rb b/modules/puppetmaster/lib/puppet/parser/functions/nodeinfo.rb index 41a071afc..1380a02ed 100644 --- a/modules/puppetmaster/lib/puppet/parser/functions/nodeinfo.rb +++ b/modules/puppetmaster/lib/puppet/parser/functions/nodeinfo.rb @@ -7,18 +7,27 @@ module Puppet::Parser::Functions require '/var/lib/puppet/lib/puppet/parser/functions/ldapinfo.rb' require '/var/lib/puppet/lib/puppet/parser/functions/whohosts.rb' - nodeinfo = function_yamlinfo(host, yamlfile) - nodeinfo['ldap'] = function_ldapinfo(host, '*') + nodeinfo = function_yamlinfo([host, yamlfile]) + nodeinfo['ldap'] = function_ldapinfo([host, '*']) unless nodeinfo['ldap']['ipHostNumber'] raise Puppet::ParseError, "Host #{host} does not have ipHostNumber values in ldap" end - nodeinfo['hoster'] = function_whohosts(nodeinfo['ldap']['ipHostNumber'], "/etc/puppet/modules/debian-org/misc/hoster.yaml") + nodeinfo['hoster'] = function_whohosts([nodeinfo['ldap']['ipHostNumber'], "/etc/puppet/modules/debian_org/misc/hoster.yaml"]) + nodeinfo['buildd'] = (nodeinfo['ldap']['purpose'].respond_to?('include?') && nodeinfo['ldap']['purpose'].include?('buildd')) + nodeinfo['timeserver'] = (nodeinfo['ldap']['purpose'].respond_to?('include?') && nodeinfo['ldap']['purpose'].include?('timeserver')) + nodeinfo['porterbox'] = (nodeinfo['ldap']['purpose'].respond_to?('include?') && nodeinfo['ldap']['purpose'].include?('porterbox')) + + if lookupvar('::mta') == 'exim4' + unless nodeinfo['heavy_exim'] + nodeinfo['smarthost'] = 'mailout.debian.org' + end + end nodeinfo['misc'] = {} - fqdn = lookupvar('fqdn') + fqdn = lookupvar('::fqdn') if fqdn and fqdn == host - v4ips = lookupvar('v4ips') - if v4ips + v4ips = lookupvar('::v4ips') + if v4ips and v4ips.to_s != "" and v4ips.to_s != 'undefined' nodeinfo['misc']['v4addrs'] = v4ips.split(',') # find out if we are behind nat @@ -26,25 +35,27 @@ module Puppet::Parser::Functions nodeinfo['misc']['natted'] = intersection.empty? end - v6ips = lookupvar('v6ips') - if v6ips and v6ips != "no" + v6ips = lookupvar('::v6ips') + if v6ips and v6ips.to_s != "" and v6ips.to_s != 'undefined' nodeinfo['misc']['v6addrs'] = v6ips.split(',') end end - if not nodeinfo['hoster']['nameservers'] or nodeinfo['hoster']['nameservers'].empty? + ns = call_function('hiera',['nameservers']) + allow_dns_q = call_function('hiera',['allow_dns_query']) + if ns.empty? # no nameservers known for this hoster nodeinfo['misc']['resolver-recursive'] = true - if nodeinfo['hoster']['allow_dns_query'] - raise Puppet::ParseError, "No nameservers listed for #{nodeinfo['hoster']['name']} yet we should answer somebody's queries? That makes no sense." + if not allow_dns_q.empty? + raise Puppet::ParseError, "No nameservers listed for #{nodeinfo['hoster']['name']} yet we should answer somebody's queries? That makes no sense. allow_dns_q: #{allow_dns_q}." end - elsif (nodeinfo['misc']['v4addrs'] and (nodeinfo['hoster']['nameservers'] & nodeinfo['misc']['v4addrs']).size > 0) or - (nodeinfo['misc']['v6addrs'] and (nodeinfo['hoster']['nameservers'] & nodeinfo['misc']['v6addrs']).size > 0) + elsif (nodeinfo['misc']['v4addrs'] and (ns & nodeinfo['misc']['v4addrs']).size > 0) or + (nodeinfo['misc']['v6addrs'] and (ns & nodeinfo['misc']['v6addrs']).size > 0) # this host is listed as a nameserver at this location nodeinfo['misc']['resolver-recursive'] = true - if not nodeinfo['hoster']['allow_dns_query'] or nodeinfo['hoster']['allow_dns_query'].empty? + if allow_dns_q.empty? raise Puppet::ParseError, "Host #{host} is listed as a nameserver for #{nodeinfo['hoster']['name']} but no allow_dns_query networks are defined for this location" end else