From 06f8e083701d1c0886668573295fa2dc7bb7980c Mon Sep 17 00:00:00 2001 From: Stephen Gran Date: Sun, 21 Feb 2010 03:19:04 +0000 Subject: [PATCH] first stab at making puppet figure out info for nagios and munin master Signed-off-by: Stephen Gran --- manifests/site.pp | 9 ++++---- modules/ferm/manifests/init.pp | 2 +- .../defs.conf => templates/defs.conf.erb} | 23 +++++++++++++++++-- modules/nagios/templates/inc-debian.org.erb | 9 +++++++- modules/samhain/templates/samhainrc.erb | 6 ++--- 5 files changed, 38 insertions(+), 11 deletions(-) rename modules/ferm/{files/defs.conf => templates/defs.conf.erb} (71%) diff --git a/manifests/site.pp b/manifests/site.pp index 1c719fe7f..35de8860a 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -48,13 +48,14 @@ node default { } } - case $hostname { - spohr: { + case extractnodeinfo($nodeinfo, 'muninmaster') { + "true": { include munin-node::master } } - case $hostname { - tchaikovsky: { + + case extractnodeinfo($nodeinfo, 'nagiosmaster') { + "true": { include nagios::server } default: { diff --git a/modules/ferm/manifests/init.pp b/modules/ferm/manifests/init.pp index 3d35bae0c..249d6b747 100644 --- a/modules/ferm/manifests/init.pp +++ b/modules/ferm/manifests/init.pp @@ -37,7 +37,7 @@ class ferm { mode => 0400, notify => Exec["ferm restart"]; "/etc/ferm/conf.d/defs.conf": - source => "puppet:///ferm/defs.conf", + content => template("ferm/defs.conf.erb"), require => Package["ferm"], mode => 0400, notify => Exec["ferm restart"]; diff --git a/modules/ferm/files/defs.conf b/modules/ferm/templates/defs.conf.erb similarity index 71% rename from modules/ferm/files/defs.conf rename to modules/ferm/templates/defs.conf.erb index 3e18b137e..82ca5f5bd 100644 --- a/modules/ferm/files/defs.conf +++ b/modules/ferm/templates/defs.conf.erb @@ -15,8 +15,27 @@ proto (tcp udp) mod state state (NEW) dport $port ACCEPT; } -@def $HOST_MUNIN = (192.25.206.33); -@def $HOST_NAGIOS = (206.12.19.118); +@def $HOST_NAGIOS = (<%= + nagii = [] + localinfo.keys.sort.each do |node| + if localinfo[node]['nagiosmaster'] == "true" + nagii << keyinfo[node][0]['ipHostNumber'] + end + end + + nagii.join(' ') +%>); + +@def $HOST_MUNIN = (<%= + munins = [] + localinfo.keys.sort.each do |node| + if localinfo[node]['muninmaster'] == "true" + munins << keyinfo[node][0]['ipHostNumber'] + end + end + + munins.join(' ') +%>); @def $sgran = (91.103.132.24/29); @def $weasel = (); diff --git a/modules/nagios/templates/inc-debian.org.erb b/modules/nagios/templates/inc-debian.org.erb index c53e7389f..70f37b0bc 100644 --- a/modules/nagios/templates/inc-debian.org.erb +++ b/modules/nagios/templates/inc-debian.org.erb @@ -4,7 +4,14 @@ ## <%= -nagii = [ '206.12.19.118', '192.25.206.33', '82.195.75.106' ] +ournag = [] +localinfo.keys.sort.each do |node| + if localinfo[node]['nagiosmaster'] == "true" + ournag << keyinfo[node][0]['ipHostNumber'] + end +end + +nagii = ournag case fqdn when 'mundy.debian.org', 'penalosa.debian.org', 'caballero.debian.org', 'peri.debian.org' then diff --git a/modules/samhain/templates/samhainrc.erb b/modules/samhain/templates/samhainrc.erb index e4afdac48..0ed6a8657 100644 --- a/modules/samhain/templates/samhainrc.erb +++ b/modules/samhain/templates/samhainrc.erb @@ -134,13 +134,13 @@ file=/etc/nagios/nrpe.d file=/etc/nagios/obsolete-packages-ignore.d file=/etc/bind/geodns <%= extradir="" -case fqdn -when "tchaikovsky.debian.org": extradir="file=/etc/nagios3/puppetconf.d +if nodeinfo['nagiosmaster'] + extradir="file=/etc/nagios3/puppetconf.d file=/etc/puppet" -else extradir="file=/etc/puppet" end extradir %> +file=/etc/puppet file=/etc/cron.d file=/usr/lib/nagios/plugins file=/usr/sbin -- 2.20.1