]> git.donarmstrong.com Git - dsa-puppet.git/blobdiff - modules/puppetmaster/lib/puppet/parser/functions/nodeinfo.rb
variable assignment does not clone string...
[dsa-puppet.git] / modules / puppetmaster / lib / puppet / parser / functions / nodeinfo.rb
index d77d65c88dd66de2ca34df4afe1f004e4a27ba17..cf8ea9dca011bdc4a996c6b53b911924ec9567ee 100644 (file)
@@ -7,13 +7,15 @@ 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['buildd'] = nodeinfo['ldap']['purpose'] && nodeinfo['ldap']['purpose'].include?('buildd')
+      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']
@@ -39,19 +41,21 @@ module Puppet::Parser::Functions
         end
       end
 
-      if not nodeinfo['hoster']['nameservers'] or nodeinfo['hoster']['nameservers'].empty?
+      ns = function_hiera(['nameservers'])
+      allow_dns_q = 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