summaryrefslogtreecommitdiff
path: root/manifests/debian.pp
blob: bb9bb38ff7fb457e8eb58ecb613ae0114650f9cf (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
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::defaults::vars::int_cfgdir}/stylesheets":
        ensure => directory,
        purge => false,
        recurse => true,
    }

    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'],
        }
        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'],
        }
        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'],
        }
    }
}