From 1c36e5c9188636aa7e5d093e2330356b24832ada Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 9 Apr 2012 23:45:16 -0400 Subject: Define a way to configure an NRPE command We need to be able to configure what NRPE commands are defined on clients. This new method accepts inline contents or a puppet source argument. Signed-off-by: Gabriel Filion --- manifests/nrpe/command.pp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 manifests/nrpe/command.pp (limited to 'manifests/nrpe/command.pp') diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp new file mode 100644 index 0000000..1da73c8 --- /dev/null +++ b/manifests/nrpe/command.pp @@ -0,0 +1,33 @@ +define nagios::nrpe::command ( + $ensure = present, + $command_line = '', + $source = '' ) +{ + if ($command_line == '' and $source == '') { + fail ( "Either one of 'command_line' or 'source' must be given to nagios::nrpe::command." ) + } + + if $nagios_nrpe_cfg_dir == '' { + $nagios_nrpe_cfgdir = $nagios::nrpe::base::nagios_nrpe_cfgdir + } + + file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg": + ensure => $ensure, + mode => 644, owner => root, group => root, + notify => Service['nagios-nrpe-server'], + require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] + } + + case $source { + '': { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + content => template( "nagios/nrpe/nrpe_command.erb" ), + } + } + default: { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + source => $source, + } + } + } +} -- cgit v1.2.3 From f9f47f1e2af2d7bd4b60c84697fcffe365b1d0dd Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Mon, 24 Jan 2011 13:21:02 -0500 Subject: Fix nagios::nrpe::command for FreeBSD The 'command' resource defines files under the root group. Since the 'root' group does not exist by default on FreeBSD, make an exception for FreeBSD to use the 'wheel' group instead. --- manifests/nrpe/command.pp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'manifests/nrpe/command.pp') diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp index 1da73c8..9c90ed7 100644 --- a/manifests/nrpe/command.pp +++ b/manifests/nrpe/command.pp @@ -18,6 +18,12 @@ define nagios::nrpe::command ( require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] } + if $operatingsystem == 'freebsd' { + File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { + group => wheel, + } + } + case $source { '': { File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { -- cgit v1.2.3 From c9de09ece4508db6b216abd0f74f07ea7befe906 Mon Sep 17 00:00:00 2001 From: Gabriel Filion Date: Tue, 1 Feb 2011 16:21:20 -0500 Subject: nrpe FreeBSD compatibility Make some changes to ensure compatibility of the nrpe resources with FreeBSD. * Use group 0 instead of 'root' * capitalize values for testing $operatingsystem * override arguments for the nrpe service so that FreeBSD can find the init script --- manifests/nrpe/command.pp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'manifests/nrpe/command.pp') diff --git a/manifests/nrpe/command.pp b/manifests/nrpe/command.pp index 9c90ed7..e6ebdae 100644 --- a/manifests/nrpe/command.pp +++ b/manifests/nrpe/command.pp @@ -13,17 +13,11 @@ define nagios::nrpe::command ( file { "$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg": ensure => $ensure, - mode => 644, owner => root, group => root, + mode => 644, owner => root, group => 0, notify => Service['nagios-nrpe-server'], require => File [ "$nagios_nrpe_cfgdir/nrpe.d" ] } - if $operatingsystem == 'freebsd' { - File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { - group => wheel, - } - } - case $source { '': { File["$nagios_nrpe_cfgdir/nrpe.d/${name}_command.cfg"] { -- cgit v1.2.3