Browse Source

Install ZNC Monit config file only when needed

This commit moves the monitoring role to the bottom of site.yml so that
it is executed after all other roles.

This is needed because the monitoring role conditionally installs Monit
configuration file based on whether some other packages have been
installed or not (such as ZNC).

This patch also adds a comment to the "monitoring" entry within the
"roles" list and a `roles/monitoring/README.md` file telling users why
the monitoring role has to come last.

Resolves #284
Lorenzo Villani 9 years ago
parent
commit
3b4bf9c591
4 changed files with 12 additions and 5 deletions
  1. 0
    4
      roles/ircbouncer/tasks/znc.yml
  2. 2
    0
      roles/monitoring/README.md
  3. 9
    0
      roles/monitoring/tasks/monit.yml
  4. 1
    1
      site.yml

+ 0
- 4
roles/ircbouncer/tasks/znc.yml View File

63
 
63
 
64
 - name: Ensure znc is a system service
64
 - name: Ensure znc is a system service
65
   service: name=znc state=started enabled=true
65
   service: name=znc state=started enabled=true
66
-
67
-- name: Copy monit service config files into place
68
-  copy: src=etc_monit_conf.d_znc dest=/etc/monit/conf.d/znc
69
-  notify: restart monit

+ 2
- 0
roles/monitoring/README.md View File

1
+This role should be enabled last in site.yml since it selectively installs configuration files
2
+based on the execution status of other roles before it.

+ 9
- 0
roles/monitoring/tasks/monit.yml View File

15
     - sshd
15
     - sshd
16
     - tomcat
16
     - tomcat
17
   notify: restart monit
17
   notify: restart monit
18
+
19
+- name: Determine if ZNC is installed
20
+  stat: path=/var/lib/znc/configs/znc.conf
21
+  register: znc_config_file
22
+
23
+- name: Copy ZNC monit service config files into place
24
+  copy: src=etc_monit_conf.d_znc dest=/etc/monit/conf.d/znc
25
+  notify: restart monit
26
+  when: znc_config_file.stat.exists == True

+ 1
- 1
site.yml View File

16
     - blog
16
     - blog
17
     - ircbouncer
17
     - ircbouncer
18
     - xmpp
18
     - xmpp
19
-    - monitoring
20
     - owncloud
19
     - owncloud
21
     - vpn
20
     - vpn
22
     - tarsnap
21
     - tarsnap
24
     - git
23
     - git
25
     - newebe
24
     - newebe
26
     - readlater
25
     - readlater
26
+    - monitoring  # Monitoring role should be last. See roles/monitoring/README.md

Loading…
Cancel
Save