Try to refactor nodeinfo.rb - Hope this doesn't break too badly
authorPeter Palfrader <peter@palfrader.org>
Tue, 26 May 2009 18:24:31 +0000 (20:24 +0200)
committerPeter Palfrader <peter@palfrader.org>
Tue, 26 May 2009 18:24:31 +0000 (20:24 +0200)
files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb
modules/debian-org/misc/local.yaml

index aa641c3..94e806c 100644 (file)
@@ -34,24 +34,14 @@ 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"
+    if yaml['host_settings'].kind_of?(Hash)
+      yaml['host_settings'].each_key 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
     end
 
     ldap = LDAP::Conn.new('db.debian.org')
index c40d45f..f6aa972 100644 (file)
@@ -65,30 +65,6 @@ footer:
   schroeder.debian.org: "- This host is using an iptables firewall.  See /etc/rc.boot/firewall{,6}"
   verdi.debian.org: "- This host is using an iptables firewall.  See /etc/ferm/ferm.conf"
   zelenka.debian.org: "Debian s390 porter system kindly provided by Zentrum fuer Informationsverarbeitung und Informationstechnik [zivit]"
-need_smarthost:
-  - ancina.debian.org
-  - allegri.debian.org
-  - piatti.debian.org
-heavy_exim:
-  - raff.debian.org
-  - gluck.debian.org
-  - merkel.debian.org
-  - spohr.debian.org
-  - draghi.debian.org
-  - master.debian.org
-  - ries.debian.org
-  - rietz.debian.org
-  - klecker.debian.org
-  - powell.debian.org
-apache2_defaultconfig:
-  - carver.debian.org
-  - draghi.debian.org
-  - duarte.debian.org
-  - piatti.debian.org
-  - rore.debian.org
-  - saens.debian.org
-  - samosa.debian.org
-  - tartini.debian.org
 services:
   bugsmaster: rietz.debian.org
   qamaster: merkel.debian.org
@@ -96,12 +72,37 @@ services:
   rtmaster: spohr.debian.org
   packagesmaster: powell.debian.org
   packagesqamaster: master.debian.org
-mail_port:
-  ancina.debian.org: 2025
-  allegri.debian.org: 2025
-  piatti.debian.org: 2025
-  kassia.debian.org: 587
-reservedaddrs:
-  ball.debian.org: "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"
+host_settings:
+  heavy_exim:
+    - raff.debian.org
+    - gluck.debian.org
+    - merkel.debian.org
+    - spohr.debian.org
+    - draghi.debian.org
+    - master.debian.org
+    - ries.debian.org
+    - rietz.debian.org
+    - klecker.debian.org
+    - powell.debian.org
+  apache2_defaultconfig:
+    - carver.debian.org
+    - draghi.debian.org
+    - duarte.debian.org
+    - piatti.debian.org
+    - rore.debian.org
+    - saens.debian.org
+    - samosa.debian.org
+    - tartini.debian.org
+  smarthost:
+    ancina.debian.org: mailout.debian.org
+    allegri.debian.org: mailout.debian.org
+    piatti.debian.org: mailout.debian.org
+  mail_port:
+    ancina.debian.org: 2025
+    allegri.debian.org: 2025
+    piatti.debian.org: 2025
+    kassia.debian.org: 587
+  reservedaddrs:
+    ball.debian.org: "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"
 ---