node default {
$localinfo = yamlinfo('*', "/etc/puppet/modules/debian-org/misc/local.yaml")
$nodeinfo = nodeinfo($fqdn, "/etc/puppet/modules/debian-org/misc/local.yaml")
- $hosterinfo = whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
$allnodeinfo = allnodeinfo("sshRSAHostKey ipHostNumber", "purpose mXRecord")
- notice("hoster for ${fqdn} is ${hosterinfo}")
include munin-node
include syslog-ng
yamlfile = args[1]
require '/var/lib/puppet/lib/puppet/parser/functions/ldapinfo.rb'
+ require '/var/lib/puppet/lib/puppet/parser/functions/whohosts.rb'
results = function_yamlinfo(host, yamlfile)
results['ldap'] = function_ldapinfo(host, '*')
+ unless results['ldap']['ipHostNumber']
+ raise Puppet::ParseError, "Host #{host} does not have ipHostNumber values in ldap"
+ end
+ results['hoster'] = whohosts(results['ldap']['ipHostNumber'], "/etc/puppet/modules/debian-org/misc/hoster.yaml")
results['misc'] = {}
fqdn = lookupvar('fqdn')
require 'ipaddr'
require 'yaml'
- nodeinfo = args[0]
+ ipAddrs = args[0]
yamlfile = args[1]
parser.watch_file(yamlfile)
ans = {"name" => "unknown"}
yaml = YAML.load_file(yamlfile)
- if (nodeinfo['ldap'].has_key?('ipHostNumber'))
- nodeinfo['ldap']['ipHostNumber'].each do |addr|
- yaml.keys.each do |hoster|
- if yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
- netrange = yaml[hoster]['netrange']
- else
- next
- end
+ ipAddrs.each do |addr|
+ yaml.keys.each do |hoster|
+ if yaml[hoster].kind_of?(Hash) and yaml[hoster].has_key?('netrange')
+ netrange = yaml[hoster]['netrange']
+ else
+ next
+ end
- netrange.each do |net|
- begin
- if IPAddr.new(net).include?(addr)
- ans = yaml[hoster]
- ans['name'] = hoster
- end
- rescue => e
- raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
+ netrange.each do |net|
+ begin
+ if IPAddr.new(net).include?(addr)
+ ans = yaml[hoster]
+ ans['name'] = hoster
end
+ rescue => e
+ raise Puppet::ParseError, "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
end
end
end
nameservers << "127.0.0.1"
end
-nameservers += hosterinfo['nameservers'] if hosterinfo['nameservers']
-searchpaths += hosterinfo['searchpaths'] if hosterinfo['searchpaths']
-options += hosterinfo['resolvoptions'] if hosterinfo['resolvoptions']
+nameservers += nodeinfo['hoster']['nameservers'] if nodeinfo['hoster']['nameservers']
+searchpaths += nodeinfo['hoster']['searchpaths'] if nodeinfo['hoster']['searchpaths']
+options += nodeinfo['hoster']['resolvoptions'] if nodeinfo['hoster']['resolvoptions']
searchpaths << "debian.org"
# local admin
-<%= hosterkeys = case hosterinfo['name']
+<%= hosterkeys = case nodeinfo['hoster']['name']
when "ubcece" then
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvEEyxznxleAhk98K7SkAeAKWibijL5uFjIl1+tr8rz+XmFsjabTK2+hQXkgzmU+jqQ2+MPp6btfAq9Oe27GQYWUFfsAZMRb907dReFQYPKbPhQZoo5LUfkrCiR3tD0Nm2JfepTV0079K1+Q50EMImttwbI94FfSoSgTxgF4rCoLpUgmF0IHDR1+kTGow7YnuS1Y/I1zKAbofg8KBGXOLArkcZbxArt25Y2wlnE+ZHIb3Rn3pYc3/KmPPvEQy9IkR/uzzkWSaCBVMFJEO0ejjWrV4HR64GlKUPQ0CekSYn1EErY55CF5sWkasXhflluwSf7b+/jedDM1A1Vrp9Z/F8Q== chrisd"
end