node default {
$localinfo = yamlinfo('*', "/etc/puppet/modules/debian-org/misc/local.yaml")
$nodeinfo = nodeinfo($fqdn, "/etc/puppet/modules/debian-org/misc/local.yaml")
- $hoster = whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
+ $hosterinfo = whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
$keyinfo = allnodeinfo("sshRSAHostKey", "ipHostNumber", "purpose")
$mxinfo = allnodeinfo("mXRecord")
- notice("hoster for ${fqdn} is ${hoster}")
+ notice("hoster for ${fqdn} is ${getfromhash(hosterinfo, "name")}")
include munin-node
include syslog-ng
case $brokenhosts {
"true": { include hosts }
}
- case $hoster {
+ case getfromhash($hosterinfo, "name") {
"ubcece", "darmstadt", "ftcollins", "grnet": { include resolv }
}
case $portforwarder_user_exists {
--- /dev/null
+module Puppet::Parser::Functions
+ newfunction(:getfromhash, :type => :rvalue) do |args|
+ h = args.shift
+ key = args.shift
+
+ raise Puppet::ParseError, "argument is not a hash" unless h.kind_of?(Hash)
+ if h.has_key?(key)
+ ans = h[key]
+ else
+ ans = false
+ end
+
+ return ans
+ end
+end
+# vim:set et:
+# vim:set sts=2 ts=2:
+# vim:set shiftwidth=2:
$KCODE = 'utf-8'
- ans = "unknown"
+ ans = {"name": "unknown"}
yaml = YAML.load_file(yamlfile)
if (nodeinfo['ldap'].has_key?('ipHostNumber'))
netrange.each do |net|
begin
if IPAddr.new(net).include?(addr)
- ans = hoster
+ ans = yaml[hoster]
+ ans['name'] = hoster
end
rescue Exception => e
raise "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
# local admin
-<%= hosterkeys = case hoster
+<%= hosterkeys = case hosterinfo['name']
when "ubcece" then
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvEEyxznxleAhk98K7SkAeAKWibijL5uFjIl1+tr8rz+XmFsjabTK2+hQXkgzmU+jqQ2+MPp6btfAq9Oe27GQYWUFfsAZMRb907dReFQYPKbPhQZoo5LUfkrCiR3tD0Nm2JfepTV0079K1+Q50EMImttwbI94FfSoSgTxgF4rCoLpUgmF0IHDR1+kTGow7YnuS1Y/I1zKAbofg8KBGXOLArkcZbxArt25Y2wlnE+ZHIb3Rn3pYc3/KmPPvEQy9IkR/uzzkWSaCBVMFJEO0ejjWrV4HR64GlKUPQ0CekSYn1EErY55CF5sWkasXhflluwSf7b+/jedDM1A1Vrp9Z/F8Q== chrisd"
end