From e7626f33b31aa30202f6dd56fa670a4de088a2e2 Mon Sep 17 00:00:00 2001 From: Ossi Salmi Date: Mon, 2 Sep 2013 15:41:17 +0300 Subject: [PATCH] nagios: Create service groups automatically --- nagios/manifests/init.pp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/nagios/manifests/init.pp b/nagios/manifests/init.pp index df354bb..818eb26 100644 --- a/nagios/manifests/init.pp +++ b/nagios/manifests/init.pp @@ -190,8 +190,8 @@ class nagios::server::manual inherits nagios::common { require => File["/etc/nagios/conf.d"], } nagios_contactgroup { "all": - target => "${confdir}/contactgroup_all.cfg", - notify => Service["nagios"], + target => "${confdir}/contactgroup_all.cfg", + notify => Service["nagios"], } file { "${confdir}/host_default.cfg": @@ -522,8 +522,8 @@ define nagios::host($address=undef, $group="NONE", $osname="NONE", require => File["/etc/nagios/conf.d"], } nagios_contactgroup { $group: - target => "${confdir}/contactgroup_${group}.cfg", - notify => Service["nagios"], + target => "${confdir}/contactgroup_${group}.cfg", + notify => Service["nagios"], } } if !defined(Nagios_hostgroup[$group]) { @@ -536,8 +536,8 @@ define nagios::host($address=undef, $group="NONE", $osname="NONE", require => File["/etc/nagios/conf.d"], } nagios_hostgroup { $group: - target => "${confdir}/hostgroup_${group}.cfg", - notify => Service["nagios"], + target => "${confdir}/hostgroup_${group}.cfg", + notify => Service["nagios"], } } Nagios_host[$name] { @@ -584,8 +584,23 @@ define nagios::service($host, $command, $description, $group="NONE", } if $group != "NONE" { + if !defined(Nagios_servicegroup[$group]) { + file { "${confdir}/servicegroup_${group}.cfg": + ensure => present, + mode => "0640", + owner => "root", + group => "nagios", + before => Nagios_servicegroup[$group], + require => File["/etc/nagios/conf.d"], + } + nagios_servicegroup { $group: + target => "${confdir}/servicegroup_${group}.cfg", + notify => Service["nagios"], + } + } Nagios_service[$name] { contact_groups => "all,${group}", + servicegroups => $group, } }