From e73743d9798dd28bef9565e667300745209b403a Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Mon, 27 Apr 2009 01:11:59 +0100 Subject: [PATCH] Lets see if putting the extra functions in git works Signed-off-by: Stephen Gran --- .../lib/puppet/parser/functions/nodeinfo.rb | 39 +++++++++++++++++++ files/etc/puppet/puppet.conf | 1 + modules/debian-org/manifests/init.pp | 15 +++++++ 3 files changed, 55 insertions(+) create mode 100644 files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb diff --git a/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb new file mode 100644 index 00000000..db16133a --- /dev/null +++ b/files/etc/puppet/lib/puppet/parser/functions/nodeinfo.rb @@ -0,0 +1,39 @@ +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 diff --git a/files/etc/puppet/puppet.conf b/files/etc/puppet/puppet.conf index 67938895..931ce3ce 100644 --- a/files/etc/puppet/puppet.conf +++ b/files/etc/puppet/puppet.conf @@ -13,3 +13,4 @@ pluginsync=true [puppetmasterd] templatedir=/etc/puppet/templates +libdir=/etc/puppet/lib diff --git a/modules/debian-org/manifests/init.pp b/modules/debian-org/manifests/init.pp index ad031655..4943c700 100644 --- a/modules/debian-org/manifests/init.pp +++ b/modules/debian-org/manifests/init.pp @@ -46,11 +46,26 @@ class debian-org { "/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, -- 2.39.2