summaryrefslogtreecommitdiff
path: root/puppet/modules/nagios/manifests/debian.pp
blob: 39af973e597eae99b71f407830da4ef1d9162638 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# debian specific things
class nagios::debian inherits nagios::base {

  Package['nagios'] { name => 'nagios3' }

  package { [ 'nagios-plugins', 'nagios-snmp-plugins','nagios-nrpe-plugin' ]:
      ensure => 'present',
      notify => Service['nagios'],
  }

  Service['nagios'] {
      name      => 'nagios3',
      hasstatus => true,
  }

  File['nagios_htpasswd', 'nagios_cgi_cfg'] { group => 'www-data' }

  file{
    'nagios_commands_cfg':
      path    => "${nagios::defaults::vars::int_cfgdir}/commands.cfg",
      notify  => Service['nagios'],
      owner   => root,
      group   => root,
      mode    => '0644',
      require => Package['nagios'];
    "${nagios::defaults::vars::int_cfgdir}/stylesheets":
      ensure  => directory,
      purge   => false,
      recurse => true,
      require => Package['nagios'];
  }

  if $nagios::allow_external_cmd {
    exec { 'nagios_external_cmd_perms_overrides':
      command   => 'dpkg-statoverride --update --add nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --update --add nagios nagios 751 /var/lib/nagios3',
      unless    => 'dpkg-statoverride --list nagios www-data 2710 /var/lib/nagios3/rw && dpkg-statoverride --list nagios nagios 751 /var/lib/nagios3',
      logoutput => false,
      notify    => Service['nagios'],
      require   => Package['nagios'],
    }
    exec { 'nagios_external_cmd_perms_1':
      command => 'chmod 0751 /var/lib/nagios3 && chown nagios:nagios /var/lib/nagios3',
      unless  => 'test "`stat -c "%a %U %G" /var/lib/nagios3`" = "751 nagios nagios"',
      notify  => Service['nagios'],
      require => Package['nagios'],
    }
    exec { 'nagios_external_cmd_perms_2':
      command => 'chmod 2751 /var/lib/nagios3/rw && chown nagios:www-data /var/lib/nagios3/rw',
      unless  => 'test "`stat -c "%a %U %G" /var/lib/nagios3/rw`" = "2751 nagios www-data"',
      notify  => Service['nagios'],
      require => Package['nagios'],
    }
  }
}