blob: 4d19054649a2399e6c1ba0d2ddda09d5f9196a08 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
##
## A playbook to set up a Nagios 4 server
##
## Setup the initial user and groups.
- name: Add nagios group as 420
group: name=nagios gid=420 state=present system=yes
tags:
- nagios_server
- name: Add nagios user as 420
user: name=nagios uid=420 state=present home=/var/spool/nagios comment="Nagios Monitoring User" createhome=yes system=yes shell=/bin/bash
tags:
- nagios_server
# Add the apache user to the nagios group so that it has permissions
# to do stuff in /var/spool/nagios/*
- name: Add apache to nagios group
user: name=apache append=yes groups=nagios
tags:
- nagios_server
## Install the initial packages for the group.
- name: Install nagios packages
yum: name={{ item }} state=present
with_items:
- php
- nagios.x86_64
- nagios-plugins
- nagios-plugins-dig
- nagios-plugins-disk
- nagios-plugins-dns
- nagios-plugins-dummy
- nagios-plugins-file_age
- nagios-plugins-http
- nagios-plugins-load
- nagios-plugins-nagios
- nagios-plugins-nrpe
- nagios-plugins-perl
- nagios-plugins-pgsql
- nagios-plugins-ping
- nagios-plugins-procs
- nagios-plugins-smtp
- nagios-plugins-ssh
- nagios-plugins-swap
- nagios-plugins-tcp
- nagios-plugins-users
- perl-Mail-IMAPClient
- stunnel
- mod_auth_gssapi
tags:
- nagios_server
## Setup directories for files to be copied
- name: Create or confirm directories to be made
file: dest={{item}} mode=0755 owner=root group=root state=directory
with_items:
- /etc/nagios/commands
- /etc/nagios/contacts
- /etc/nagios/contactgroups
- /etc/nagios/hosts
- /etc/nagios/hostgroups
- /etc/nagios/services
- /etc/nagios/servicegroups
- /etc/nagios/conf.d
- /usr/lib64/nagios/plugins/
- /usr/lib64/nagios/plugins/eventhandlers/
## Remove the items we don't want
- name: Nuke default nagios passwd
file: dest=/etc/nagios/passwd state=absent
tags:
- nagios_server
- name: Nuke default nagios objects
file: dest=/etc/nagios/objects state=absent
tags:
- nagios_server
## Copy over system configs
# TODO: Make this a template once they're closer together
- name: Copy httpd config (production)
copy: src=httpd/nagios.conf dest=/etc/httpd/conf.d/nagios.conf
when: env == "production"
tags:
- nagios_server
- name: Copy httpd config (staging)
copy: src=httpd/nagios-new.conf dest=/etc/httpd/conf.d/nagios.conf
when: env == "staging"
tags:
- nagios_server
- name: Copy specialized nrpe.cfg for nagios server
copy: src=nrpe/nrpe.cfg dest=/etc/nagios/nrpe.cfg mode=0644 group=root owner=root
notify:
- restart nrpe
tags:
- config
- nagios_server
## Copy over the nagios configs
- name: Copy /etc/nagios/conf.d/*cfg files
copy: src=nagios/configs/{{ item }} dest=/etc/nagios/conf.d/{{ item }}
with_items:
- escalations.cfg
- timeperiods.cfg
tags:
- config
- nagios_server
- name: Copy over the main conf file
copy: src=nagios/configs/nagios.cfg dest=/etc/nagios mode=0644 group=root owner=root
tags:
- config
- nagios_server
## Copy over the command scripts
- name: Copy /etc/nagios/commands
synchronize: src=nagios/commands/ dest=/etc/nagios/commands/
tags:
- nagios-config
- nagios_server
notify: restart nagios
## Copy over the contacts
- name: Copy /etc/nagios/contacts
synchronize: src=nagios/contacts/ dest=/etc/nagios/contacts/
tags:
- nagios-config
- nagios_server
notify: restart nagios
## Copy over the contactgroups
- name: Copy /etc/nagios/contactgroups
synchronize: src=nagios/contactgroups/ dest=/etc/nagios/contactgroups/
tags:
- nagios-config
- nagios_server
notify: restart nagios
## Copy over the hosts
- name: Copy /etc/nagios/hosts
copy: src=nagios/hosts/ dest=/etc/nagios/hosts/
tags:
- nagios-config
- nagios_server
notify: restart nagios
## Copy over the services
- name: Copy /etc/nagios/services (production)
copy: src=nagios/services/{{ item }} dest=/etc/nagios/services/{{ item }}
with_items:
- autocloud.cfg
- basset.cfg
- copr.cfg
- db_backups.cfg
- disk.cfg
- dns.cfg
- fedmsg.cfg
- file_age.cfg
- fmn.cfg
- haproxy.cfg
- hosted.cfg
- ipa.cfg
- koji.cfg
- koschei.cfg
- locking.cfg
- mail_queue.cfg
- memcached.cfg
- nagios.cfg
- nrpe.cfg
- osbs.cfg
- pgsql.cfg
- ping.cfg
- procs.cfg
- raid.cfg
- smtp-mm.cfg
- ssh.cfg
- ssl.cfg
- swap.cfg
- unbound.cfg
- vpnclients.cfg
- websites.cfg
- templates.cfg
tags:
- nagios-config
- nagios_server
when: env == "production"
notify: restart nagios
## Copy over the services
- name: Copy /etc/nagios/services (staging)
copy: src=nagios/services/{{ item }} dest=/etc/nagios/services/{{ item }}
with_items:
- mail_queue.cfg
- ping.cfg
- templates.cfg
tags:
- nagios-config
- nagios_server
when: env == "staging"
notify: restart nagios
## Copy over the servicegroups
- name: Copy /etc/nagios/servicegroups
synchronize: src=nagios/servicegroups/ dest=/etc/nagios/servicegroups/
tags:
- nagios-config
- nagios_server
notify: restart nagios
## Copy over the plugins
- name: Copy plugins
copy: src=nagios/plugins/ dest=/usr/lib64/nagios/plugins/ mode=0755 owner=root group=root
tags:
- nagios_server
## Copy over the programs
- name: Copy irc-colorize.py
copy: src=nagios/scripts/irc-colorize.py dest=/usr/local/bin/irc-colorize.py mode=0755 group=root owner=root
tags:
- nagios_server
- name: Copy check_nagios_notifications.py
copy: src=nagios/scripts/check_nagios_notifications.py dest=/usr/local/bin/check_nagios_notifications.py mode=0755 group=root owner=root
tags:
- nagios_server
## Build template files
# This one may go to being just a regular config file if we can make remote monitoring work
- name: Template out the cgi.cfg
template: src=nagios/configs/cgi.cfg.j2 dest=/etc/nagios/cgi.cfg mode=0644 owner=root group=root
tags:
- nagios_server
- name: Override config.inc.php for the given environment
template: src=nagios/config.inc.php.j2 dest=/usr/share/nagios/html/config.inc.php mode=0640 owner=root group=apache
tags:
- nagios_server
- name: Template over services
template: src=nagios/services/{{item}}.j2 dest=/etc/nagios/services/{{item}} mode=0644 owner=root group=root
with_items:
- phx2-mgmt.cfg
tags:
- nagios_server
- name: Build out nagios host templates (production)
template: src=nagios/hosts/{{item}}.j2 dest=/etc/nagios/hosts/{{item}} mode=0644 owner=root group=root
with_items:
- bodhost-hosts.cfg
- cloud-hosts.cfg
- coloamer-hosts.cfg
- dedicatedsolutions-hosts.cfg
- host1plus-hosts.cfg
- ibiblio-hosts.cfg
- internetx-hosts.cfg
- osuosl-hosts.cfg
- phx2-hosts.cfg
- staging-hosts.cfg
- phx2-mgmt-hosts.cfg
- rdu-cc-hosts.cfg
- rdu-hosts.cfg
- tummy-hosts.cfg
when: env == "production"
tags:
- nagios_server
- name: Build out nagios host templates (staging)
template: src=nagios/hosts/{{item}}.j2 dest=/etc/nagios/hosts/{{item}} mode=0644 owner=root group=root
with_items:
- phx2-hosts.cfg
- staging-hosts.cfg
- phx2-mgmt-hosts.cfg
when: env == "staging"
tags:
- nagios_server
- name: Build out nagios hostgroup templates
template: src=nagios/hostgroups/{{item}}.j2 dest=/etc/nagios/hostgroups/{{item}} mode=0644 owner=root group=root
with_items:
- all.cfg
- nomail.cfg
- noswap.cfg
tags:
- nagios_server
- name: Build out nagios servicegroup templates
template: src=nagios/servicegroups/{{item}}.j2 dest=/etc/nagios/servicegroups/{{item}} mode=0644 owner=root group=root
with_items:
- bodhi.cfg
- freemedia.cfg
- mgmt-https.cfg
- pkgdb.cfg
- fas.cfg
- fp-wiki.cfg
- ipa.cfg
- mgmt-http.cfg
- mirrorlist.cfg
tags:
- nagios_server
## Copy over the servicedeps
## Setup the cron jobs
- name: Install check_nagios_notifications cron
cron: name="check_nagios_notifications" minute=0 hour=0 weekday=1 user=nagios job="/usr/local/bin/check_nagios_notifications.py"
tags:
- nagios_server
## Handle selinux annoyances - roughly copied from fedmsg role
- name: Ensure a directory exists for our custom selinux module
file: dest=/usr/local/share/nagios-policy state=directory
tags:
- nagios_server
- name: Copy over our custom selinux module
copy: src=selinux/nagios_hostname.pp dest=/usr/local/share/nagios-policy/nagios_hostname.pp
register: selinux_module
tags:
- nagios_server
- name: Install our custom selinux module
command: semodule -i /usr/local/share/nagios-policy/nagios_hostname.pp
when: selinux_module|changed
tags:
- nagios_server
|