--- /dev/null
+module Puppet::Parser::Functions
+ newfunction(:nodeinfo, :type => :rvalue) do |args|
+
+ host = args[0]
+ yamlfile = args[1]
+ parser.watch_file(yamlfile)
+
+ require 'ldap'
+ require 'yaml'
+
+ $KCODE = 'utf-8'
+
+ yaml = YAML.load_file(yamlfile)
+ results = {}
+
+ ['nameinfo', 'footer'].each do |detail|
+ if yaml.has_key?(detail)
+ if yaml[detail].has_key?(host)
+ results[detail] = yaml[detail][host]
+ end
+ end
+ end
+
+ ldap = LDAP::Conn.new('samosa.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
+ end
+ rescue LDAP::ResultError
+ rescue RuntimeError
+ ensure
+ ldap.unbind
+ end
+ return(results)
+ end
+end
"/etc/default/puppet":
source => "puppet:///files/etc/default/puppet",
notify => Exec["puppet restart"];
+ case $hostname {
+ spohr: {
+ "/etc/puppet/lib":
+ ensure => directory,
+ source => "puppet:///files/etc/puppet/lib",
+ recurse => true,
+ notify => Exec["puppetmaster restart"];
+ }
+ default: {}
+ }
}
+
exec { "puppet reload":
path => "/etc/init.d:/usr/bin:/usr/sbin:/bin:/sbin",
refreshonly => true,
}
+ exec { "puppetmaster restart":
+ path => "/etc/init.d:/usr/bin:/usr/sbin:/bin:/sbin",
+ refreshonly => true,
+ }
exec { "puppet restart":
path => "/etc/init.d:/usr/bin:/usr/sbin:/bin:/sbin",
refreshonly => true,