OK, so that method of addressing them didn't work
[mirror/dsa-puppet.git] / files / etc / puppet / lib / puppet / parser / functions / nodeinfo.rb
index aa641c3..5223752 100644 (file)
@@ -34,40 +34,17 @@ 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"
-    end
-
-    if yaml.has_key?('apache2_defaultconfig') and yaml['apache2_defaultconfig'].include?(host)
-      results['apache2_defaultconfig']    = "true"
-    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
+    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
-    rescue LDAP::ResultError
-    rescue RuntimeError
-    ensure
-      ldap.unbind
     end
-    return(results)
+
+    results['ldap'] = ldapinfo(host, '*')
   end
 end