hoster
Signed-off-by: Stephen Gran <steve@lobefin.net>
--- /dev/null
+module Puppet::Parser::Functions
+ newfunction(:whohosts, :type => :rvalue) do |args|
+ require 'ipaddr'
+ require 'yaml'
+
+ nodeinfo = args[0]
+ yamlfile = args[1]
+ parser.watch_file(yamlfile)
+
+ $KCODE = 'utf-8'
+
+ ans = "unknown"
+ yaml = YAML.load_file(yamlfile)
+
+ if (nodeinfo['ldap'].at(0)) and (nodeinfo['ldap'][0].has_key?('ipHostNumber'))
+ nodeinfo['ldap'][0]['ipHostNumber'].each do |addr|
+ yaml.keys.each do |hoster|
+ yaml[hoster].each do |net|
+ if IPAddr.new(net).include?(addr)
+ ans = hoster
+ end
+ end
+ end
+ end
+ end
+ return ans
+ end
+end
node default {
$nodeinfo = nodeinfo($fqdn, "/etc/puppet/modules/debian-org/misc/local.yaml")
+ $hoster = whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
include munin-node
include sudo
--- /dev/null
+---
+darmstadt:
+ - 82.195.75.64/26
+ - 2001:41b8:202:deb::/64
+ftcollins:
+ - 192.25.206.0/24
+ubcece:
+ - 137.82.84.64/27
+ - 206.12.19.0/24
+---