瀏覽代碼

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 10 年之前
父節點
當前提交
3b4bf9c591
共有 4 個文件被更改,包括 12 次插入5 次删除
  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 查看文件

@@ -63,7 +63,3 @@
63 63
 
64 64
 - name: Ensure znc is a system service
65 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 查看文件

@@ -0,0 +1,2 @@
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 查看文件

@@ -15,3 +15,12 @@
15 15
     - sshd
16 16
     - tomcat
17 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 查看文件

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

Loading…
取消
儲存