summaryrefslogtreecommitdiff
path: root/manifests/nrpe/command.pp
blob: e6ebdae21af9eb4b10d8a9d48245fc05711bfa62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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 => 0,
                    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,
            }
        }
    }
}