parts of the nagios setup
[mirror/dsa-puppet.git] / modules / nagios / manifests / server.pp
1 class nagios::server {
2         include apache2
3         include apache2::ssl
4         include apache2::authn_anon
5
6         ssl::service { 'nagios.debian.org':
7                 notify  => Exec['service apache2 reload'],
8                 key => true,
9         }
10         apache2::site { "10-nagios.debian.org":
11                 site => "nagios.debian.org",
12                 content => template('nagios/nagios.debian.org.conf.erb'),
13         }
14
15         ensure_packages( [
16                 'icinga',
17                 'make',
18                 'monitoring-plugins',
19                 'nagios-nrpe-plugin',
20                 ], { ensure => 'installed' })
21
22         service { 'icinga':
23                 ensure => running,
24                 require => Package['icinga'],
25         }
26
27         file { '/etc/icinga/apache2.conf':
28                 content => template('nagios/icinga-apache2.conf.erb'),
29                 notify  => Exec['service apache2 reload'],
30         }
31         file { '/srv/nagios.debian.org/htpasswd':
32                 mode => '0640',
33                 owner => 'root',
34                 group => 'www-data',
35         }
36         file { '/etc/icinga/cgi.cfg':
37                 ensure => symlink,
38                 target => 'config-pushed/static/cgi.cfg',
39                 notify  => Exec['service apache2 reload'],
40         }
41         file { '/etc/icinga/icinga.cfg':
42                 ensure => symlink,
43                 target => 'config-pushed/static/icinga.cfg',
44                 notify  => Service['icinga'],
45         }
46         file { '/etc/icinga/objects':
47                 ensure  => directory,
48                 mode    => '755',
49                 purge   => true,
50                 recurse => true,
51                 force   => true,
52                 source  => "puppet:///files/empty/",
53                 notify  => Service['icinga'],
54         }
55         file { '/etc/icinga/objects/contacts.cfg':
56                 ensure => symlink,
57                 target => '../config-pushed/static/objects/contacts.cfg',
58                 notify  => Service['icinga'],
59         }
60         file { '/etc/icinga/objects/generic-host.cfg':
61                 ensure => symlink,
62                 target => '../config-pushed/static/objects/generic-host.cfg',
63                 notify  => Service['icinga'],
64         }
65         file { '/etc/icinga/objects/generic-service.cfg':
66                 ensure => symlink,
67                 target => '../config-pushed/static/objects/generic-service.cfg',
68                 notify  => Service['icinga'],
69         }
70         file { '/etc/icinga/objects/timeperiods.cfg':
71                 ensure => symlink,
72                 target => '../config-pushed/static/objects/timeperiods.cfg',
73                 notify  => Service['icinga'],
74         }
75
76         file { '/etc/icinga/objects/xauto-dependencies.cfg':
77                 ensure => symlink,
78                 target => '../config-pushed/generated/auto-dependencies.cfg',
79                 notify  => Service['icinga'],
80         }
81         file { '/etc/icinga/objects/xauto-hostgroups.cfg':
82                 ensure => symlink,
83                 target => '../config-pushed/generated/auto-hostgroups.cfg',
84                 notify  => Service['icinga'],
85         }
86         file { '/etc/icinga/objects/xauto-hosts.cfg':
87                 ensure => symlink,
88                 target => '../config-pushed/generated/auto-hosts.cfg',
89                 notify  => Service['icinga'],
90         }
91         file { '/etc/icinga/objects/xauto-servicegroups.cfg':
92                 ensure => symlink,
93                 target => '../config-pushed/generated/auto-servicegroups.cfg',
94                 notify  => Service['icinga'],
95         }
96         file { '/etc/icinga/objects/xauto-services.cfg':
97                 ensure => symlink,
98                 target => '../config-pushed/generated/auto-services.cfg',
99                 notify  => Service['icinga'],
100         }
101
102         file { '/etc/nagios-plugins/config/local-dsa-checkcommands.cfg':
103                 ensure => symlink,
104                 target => '../../icinga/config-pushed/static/checkcommands.cfg',
105                 notify  => Service['icinga'],
106         }
107         file { '/etc/nagios-plugins/config/local-dsa-eventhandlers.cfg':
108                 ensure => symlink,
109                 target => '../../icinga/config-pushed/static/eventhandlers.cfg',
110                 notify  => Service['icinga'],
111         }
112
113         file { '/etc/icinga/config-pushed':
114                 ensure => symlink,
115                 target => '/srv/nagios.debian.org/config-pushed'
116         }
117
118         file { '/srv/nagios.debian.org':
119                 ensure => directory,
120                 mode => '0755',
121         }
122         file { '/srv/nagios.debian.org/config-pushed':
123                 ensure => directory,
124                 mode => '0755',
125                 owner  => 'nagiosadm',
126                 group  => 'nagiosadm',
127         }
128
129         concat::fragment { 'dsa-puppet-stuff--nagios--restart-stale-icinga':
130                 target => '/etc/cron.d/dsa-puppet-stuff',
131                 order  => '010',
132                 content  => @(EOF)
133                         */15 * * * * root find /var/lib/icinga/status.dat -mmin +20 | grep -q . && service icinga restart
134                         | EOF
135         }
136 }