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 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