move exim vs. postfix, heavy vs. not, into hiera
[mirror/dsa-puppet.git] / modules / nagios / manifests / server.pp
1 # our nagios server class
2 #
3 # it includes stored ferm configs for all the things it needs to access
4 # which are then collected by the monitored services
5 class nagios::server {
6   include apache2
7   include apache2::ssl
8   include apache2::authn_anon
9
10   ssl::service { 'nagios.debian.org':
11     notify => Exec['service apache2 reload'],
12     key    => true,
13   }
14   apache2::site { '10-nagios.debian.org':
15     site    => 'nagios.debian.org',
16     content => template('nagios/nagios.debian.org.conf.erb'),
17   }
18
19   ensure_packages( [
20     'icinga',
21     'make',
22     'monitoring-plugins',
23     'nagios-nrpe-plugin',
24     ], { ensure => 'installed' })
25
26   service { 'icinga':
27     ensure  => running,
28     require => Package['icinga'],
29   }
30
31   file { '/etc/icinga/apache2.conf':
32     content => template('nagios/icinga-apache2.conf.erb'),
33     notify  => Exec['service apache2 reload'],
34   }
35   file { '/srv/nagios.debian.org/htpasswd':
36     mode  => '0640',
37     owner => 'root',
38     group => 'www-data',
39   }
40   file { '/etc/icinga/cgi.cfg':
41     ensure => symlink,
42     target => 'config-pushed/static/cgi.cfg',
43     notify => Exec['service apache2 reload'],
44   }
45   file { '/etc/icinga/icinga.cfg':
46     ensure => symlink,
47     target => 'config-pushed/static/icinga.cfg',
48     notify => Service['icinga'],
49   }
50   file { '/etc/icinga/objects':
51     ensure  => directory,
52     mode    => '0755',
53     purge   => true,
54     recurse => true,
55     force   => true,
56     source  => 'puppet:///files/empty/',
57     notify  => Service['icinga'],
58   }
59   file { '/etc/icinga/objects/contacts.cfg':
60     ensure => symlink,
61     target => '../config-pushed/static/objects/contacts.cfg',
62     notify => Service['icinga'],
63   }
64   file { '/etc/icinga/objects/generic-host.cfg':
65     ensure => symlink,
66     target => '../config-pushed/static/objects/generic-host.cfg',
67     notify => Service['icinga'],
68   }
69   file { '/etc/icinga/objects/generic-service.cfg':
70     ensure => symlink,
71     target => '../config-pushed/static/objects/generic-service.cfg',
72     notify => Service['icinga'],
73   }
74   file { '/etc/icinga/objects/timeperiods.cfg':
75     ensure => symlink,
76     target => '../config-pushed/static/objects/timeperiods.cfg',
77     notify => Service['icinga'],
78   }
79
80   file { '/etc/icinga/objects/xauto-dependencies.cfg':
81     ensure => symlink,
82     target => '../config-pushed/generated/auto-dependencies.cfg',
83     notify => Service['icinga'],
84   }
85   file { '/etc/icinga/objects/xauto-hostgroups.cfg':
86     ensure => symlink,
87     target => '../config-pushed/generated/auto-hostgroups.cfg',
88     notify => Service['icinga'],
89   }
90   file { '/etc/icinga/objects/xauto-hosts.cfg':
91     ensure => symlink,
92     target => '../config-pushed/generated/auto-hosts.cfg',
93     notify => Service['icinga'],
94   }
95   file { '/etc/icinga/objects/xauto-servicegroups.cfg':
96     ensure => symlink,
97     target => '../config-pushed/generated/auto-servicegroups.cfg',
98     notify => Service['icinga'],
99   }
100   file { '/etc/icinga/objects/xauto-services.cfg':
101     ensure => symlink,
102     target => '../config-pushed/generated/auto-services.cfg',
103     notify => Service['icinga'],
104   }
105
106   file { '/etc/nagios-plugins/config/local-dsa-checkcommands.cfg':
107     ensure => symlink,
108     target => '../../icinga/config-pushed/static/checkcommands.cfg',
109     notify => Service['icinga'],
110   }
111   file { '/etc/nagios-plugins/config/local-dsa-eventhandlers.cfg':
112     ensure => symlink,
113     target => '../../icinga/config-pushed/static/eventhandlers.cfg',
114     notify => Service['icinga'],
115   }
116
117   file { '/etc/icinga/config-pushed':
118     ensure => symlink,
119     target => '/srv/nagios.debian.org/config-pushed'
120   }
121
122   file { '/srv/nagios.debian.org':
123     ensure => directory,
124     mode   => '0755',
125   }
126   file { '/srv/nagios.debian.org/config-pushed':
127     ensure => directory,
128     mode   => '0755',
129     owner  => 'nagiosadm',
130     group  => 'nagiosadm',
131   }
132
133   concat::fragment { 'puppet-crontab--nagios--restart-stale-icinga':
134     target  => '/etc/cron.d/puppet-crontab',
135     order   => '010',
136     content => @(EOF)
137       */15 * * * * root find /var/lib/icinga/status.dat -mmin +20 | grep -q . && service icinga restart
138       | EOF
139   }
140
141   # The nagios server wants to do DNS queries on the primaries
142   @@ferm::rule::simple { "dsa-bind-from-${::fqdn}":
143     tag         => [
144                     'named::primary::ferm',
145                     'named::keyring::ferm',
146     ],
147     description => 'Allow nagios master access to the primary for checks',
148     proto       => ['udp', 'tcp'],
149     port        => 'domain',
150     saddr       => $base::public_addresses,
151   }
152
153   # The nagios server wants to connect to the NRPE server on all the hosts
154   @@ferm::rule::simple { "dsa-nrpe-from-${::fqdn}":
155     tag         => 'nagios-nrpe::server',
156     description => 'Allow nagios master access to the nrpe daemon',
157     port        => '5666',
158     saddr       => $base::public_addresses,
159   }
160   @@concat::fragment { "nrpe-debian-allow-${::fqdn}":
161     tag     => 'nagios-nrpe::server::debianorg.cfg',
162     target  => '/etc/nagios/nrpe.d/debianorg.cfg',
163     content => "allowed_hosts=${ $base::public_addresses.join(', ') }",
164   }
165 }