projects
/
mirror
/
dsa-puppet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
11a422d
)
Try returning an info hash for a hoster - this will fail
author
Peter Palfrader
<peter@palfrader.org>
Tue, 1 Mar 2011 10:50:22 +0000
(11:50 +0100)
committer
Peter Palfrader
<peter@palfrader.org>
Tue, 1 Mar 2011 10:50:22 +0000
(11:50 +0100)
manifests/site.pp
patch
|
blob
|
history
modules/puppetmaster/lib/puppet/parser/functions/getfromhash.rb
[new file with mode: 0644]
patch
|
blob
modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
patch
|
blob
|
history
modules/resolv/templates/resolv.conf.erb
patch
|
blob
|
history
modules/ssh/templates/authorized_keys.erb
patch
|
blob
|
history
diff --git
a/manifests/site.pp
b/manifests/site.pp
index
3e5e5f3
..
895a84d
100644
(file)
--- a/
manifests/site.pp
+++ b/
manifests/site.pp
@@
-16,10
+16,10
@@
Exec {
node default {
$localinfo = yamlinfo('*', "/etc/puppet/modules/debian-org/misc/local.yaml")
$nodeinfo = nodeinfo($fqdn, "/etc/puppet/modules/debian-org/misc/local.yaml")
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")
+ $hoster
info
= whohosts($nodeinfo, "/etc/puppet/modules/debian-org/misc/hoster.yaml")
$keyinfo = allnodeinfo("sshRSAHostKey", "ipHostNumber", "purpose")
$mxinfo = allnodeinfo("mXRecord")
$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
include munin-node
include syslog-ng
@@
-122,7
+122,7
@@
node default {
case $brokenhosts {
"true": { include hosts }
}
case $brokenhosts {
"true": { include hosts }
}
- case
$hoster
{
+ case
getfromhash($hosterinfo, "name")
{
"ubcece", "darmstadt", "ftcollins", "grnet": { include resolv }
}
case $portforwarder_user_exists {
"ubcece", "darmstadt", "ftcollins", "grnet": { include resolv }
}
case $portforwarder_user_exists {
diff --git a/modules/puppetmaster/lib/puppet/parser/functions/getfromhash.rb
b/modules/puppetmaster/lib/puppet/parser/functions/getfromhash.rb
new file mode 100644
(file)
index 0000000..
e948929
--- /dev/null
+++ b/
modules/puppetmaster/lib/puppet/parser/functions/getfromhash.rb
@@ -0,0
+1,18
@@
+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:
diff --git
a/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
b/modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
index
780afa1
..
022ca89
100644
(file)
--- a/
modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
+++ b/
modules/puppetmaster/lib/puppet/parser/functions/whohosts.rb
@@
-9,7
+9,7
@@
module Puppet::Parser::Functions
$KCODE = 'utf-8'
$KCODE = 'utf-8'
- ans =
"unknown"
+ ans =
{"name": "unknown"}
yaml = YAML.load_file(yamlfile)
if (nodeinfo['ldap'].has_key?('ipHostNumber'))
yaml = YAML.load_file(yamlfile)
if (nodeinfo['ldap'].has_key?('ipHostNumber'))
@@
-24,7
+24,8
@@
module Puppet::Parser::Functions
netrange.each do |net|
begin
if IPAddr.new(net).include?(addr)
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}"
end
rescue Exception => e
raise "Error while trying to match addr #{addr} for net #{net}: #{e.message}\n#{e.backtrace}"
diff --git
a/modules/resolv/templates/resolv.conf.erb
b/modules/resolv/templates/resolv.conf.erb
index
84c9836
..
e5ddafe
100644
(file)
--- a/
modules/resolv/templates/resolv.conf.erb
+++ b/
modules/resolv/templates/resolv.conf.erb
@@
-8,7
+8,7
@@
nameservers = []
searchpaths = []
resolvconf = ''
searchpaths = []
resolvconf = ''
-case hoster
+case hoster
info["name"]
when "darmstadt" then
case hostname
when "draghi", "liszt" then
when "darmstadt" then
case hostname
when "draghi", "liszt" then
diff --git
a/modules/ssh/templates/authorized_keys.erb
b/modules/ssh/templates/authorized_keys.erb
index
2d99152
..
2a546eb
100644
(file)
--- a/
modules/ssh/templates/authorized_keys.erb
+++ b/
modules/ssh/templates/authorized_keys.erb
@@
-1,5
+1,5
@@
# local admin
# local admin
-<%= hosterkeys = case hoster
+<%= hosterkeys = case hoster
info['name']
when "ubcece" then
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvEEyxznxleAhk98K7SkAeAKWibijL5uFjIl1+tr8rz+XmFsjabTK2+hQXkgzmU+jqQ2+MPp6btfAq9Oe27GQYWUFfsAZMRb907dReFQYPKbPhQZoo5LUfkrCiR3tD0Nm2JfepTV0079K1+Q50EMImttwbI94FfSoSgTxgF4rCoLpUgmF0IHDR1+kTGow7YnuS1Y/I1zKAbofg8KBGXOLArkcZbxArt25Y2wlnE+ZHIb3Rn3pYc3/KmPPvEQy9IkR/uzzkWSaCBVMFJEO0ejjWrV4HR64GlKUPQ0CekSYn1EErY55CF5sWkasXhflluwSf7b+/jedDM1A1Vrp9Z/F8Q== chrisd"
end
when "ubcece" then
"ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAvEEyxznxleAhk98K7SkAeAKWibijL5uFjIl1+tr8rz+XmFsjabTK2+hQXkgzmU+jqQ2+MPp6btfAq9Oe27GQYWUFfsAZMRb907dReFQYPKbPhQZoo5LUfkrCiR3tD0Nm2JfepTV0079K1+Q50EMImttwbI94FfSoSgTxgF4rCoLpUgmF0IHDR1+kTGow7YnuS1Y/I1zKAbofg8KBGXOLArkcZbxArt25Y2wlnE+ZHIb3Rn3pYc3/KmPPvEQy9IkR/uzzkWSaCBVMFJEO0ejjWrV4HR64GlKUPQ0CekSYn1EErY55CF5sWkasXhflluwSf7b+/jedDM1A1Vrp9Z/F8Q== chrisd"
end