summaryrefslogtreecommitdiff
path: root/manifests/nrpe/command.pp
blob: bdd89a70632e45c428efe99535f6c3ff22776c55 (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
34
# manage an nrpe command
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.' )
  }

  $cfg_dir = $nagios::nrpe::real_cfg_dir

  file{"${cfg_dir}/nrpe.d/${name}_command.cfg":
    ensure  => $ensure,
    notify  => Service['nagios-nrpe-server'],
    require => File ["${cfg_dir}/nrpe.d" ],
    owner   => 'root',
    group   => 0,
    mode    => '0644';
  }

  case $source {
    '': {
      File["${cfg_dir}/nrpe.d/${name}_command.cfg"] {
        content => template('nagios/nrpe/nrpe_command.erb'),
      }
    }
    default: {
      File["${cfg_dir}/nrpe.d/${name}_command.cfg"] {
        source => $source,
      }
    }
  }
}