No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

monit.yml 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. - name: Add monitoring vhost to apache
  2. template: src=etc_apache2_sites-available_00-status.conf dest=/etc/apache2/sites-available/00-status.conf
  3. - name: Enable the status vhost
  4. command: a2ensite 00-status.conf creates=/etc/apache2/sites-enabled/00-status.conf
  5. notify: restart apache
  6. - name: Install monit
  7. apt:
  8. name: monit
  9. state: present
  10. tags:
  11. - dependencies
  12. - name: Copy monit master config file into place
  13. template: src=etc_monit_monitrc.j2 dest=/etc/monit/monitrc
  14. notify: restart monit
  15. - name: Determine if ZNC is installed
  16. stat: path=/usr/lib/znc/configs/znc.conf
  17. register: znc_config_file
  18. - name: Determine if XMPP is installed
  19. stat: path=/etc/prosody/prosody.cfg.lua
  20. register: prosody_config_file
  21. - name: Determine if Fathom is installed
  22. stat: path=/usr/local/bin/fathom
  23. register: fathom_config_file
  24. - name: Determine if Redis is installed
  25. stat: path=/etc/redis/redis.conf
  26. register: redis_config_file
  27. - name: Determine if RSpamD is installed
  28. stat: path=/etc/rspamd/rspamd.conf
  29. register: rspamd_config_file
  30. - name: Determine if gitea is installed
  31. stat: path=/etc/gitea/app.ini
  32. register: gitea_config_file
  33. - name: Determine if Synapse is installed
  34. stat: path=/etc/matrix-synapse/homeserver.yaml
  35. register: synapse_config_file
  36. - name: Determine if Mastodon is installed
  37. stat: path=/home/mastodon/mastodon
  38. register: mastodon_config_file
  39. - name: Determine if Commento is installed
  40. stat: path=/home/{{ main_user_name }}/commento/commento
  41. register: commento_config_file
  42. - name: Determine if Grafana is installed
  43. stat: path=/etc/grafana/grafana.ini
  44. register: grafana_config_file
  45. - name: Determine if InfluxDB is installed
  46. stat: path=/etc/influxdb/influxdb.conf
  47. register: influxdb_config_file
  48. - name: Determine if Telegraf is installed
  49. stat: path=/etc/telegraf/telegraf.conf
  50. register: telegraf_config_file
  51. - name: Determine if Mosquitto is installed
  52. stat: path=/etc/mosquitto/mosquitto.conf
  53. register: mosquitto_config_file
  54. - name: Determine if OpenVPN is installed
  55. stat: path=/etc/openvpn/server.conf
  56. register: openvpn_config_file
  57. - name: Copy ZNC monit service config files into place
  58. copy: src=etc_monit_conf.d_znc dest=/etc/monit/conf.d/znc
  59. notify: restart monit
  60. when: znc_config_file.stat.exists == True
  61. - name: Copy XMPP monit service config files into place
  62. copy: src=etc_monit_conf.d_prosody dest=/etc/monit/conf.d/prosody
  63. notify: restart monit
  64. when: prosody_config_file.stat.exists == True
  65. - name: Copy Fathom monit service config files into place
  66. copy: src=etc_monit_conf.d_fathom dest=/etc/monit/conf.d/fathom
  67. notify: restart monit
  68. when: fathom_config_file.stat.exists == True
  69. - name: Copy Redis monit service config files into place
  70. copy: src=etc_monit_conf.d_redis dest=/etc/monit/conf.d/redis
  71. notify: restart monit
  72. when: redis_config_file.stat.exists == True
  73. - name: Copy RSpamD monit service config files into place
  74. copy: src=etc_monit_conf.d_rspamd dest=/etc/monit/conf.d/rspamd
  75. notify: restart monit
  76. when: rspamd_config_file.stat.exists == True
  77. - name: Copy gitea monit service config files into place
  78. copy: src=etc_monit_conf.d_gitea dest=/etc/monit/conf.d/gitea
  79. notify: restart monit
  80. when: gitea_config_file.stat.exists == True
  81. - name: Copy Synapse monit service config files into place
  82. copy: src=etc_monit_conf.d_matrix dest=/etc/monit/conf.d/matrix
  83. notify: restart monit
  84. when: synapse_config_file.stat.exists == True
  85. - name: Copy Mastodon monit service config files into place
  86. copy: src=etc_monit_conf.d_mastodon dest=/etc/monit/conf.d/mastodon
  87. notify: restart monit
  88. when: mastodon_config_file.stat.exists == True
  89. - name: Copy Commento monit service config files into place
  90. copy: src=etc_monit_conf.d_commento dest=/etc/monit/conf.d/commento
  91. notify: restart monit
  92. when: commento_config_file.stat.exists == True
  93. - name: Copy Grafana monit service config files into place
  94. copy: src=etc_monit_conf.d_grafana dest=/etc/monit/conf.d/grafana
  95. notify: restart monit
  96. when: grafana_config_file.stat.exists == True
  97. - name: Copy InfluxDB monit service config files into place
  98. copy: src=etc_monit_conf.d_influxdb dest=/etc/monit/conf.d/influxdb
  99. notify: restart monit
  100. when: influxdb_config_file.stat.exists == True
  101. - name: Copy Telegraf monit service config files into place
  102. copy: src=etc_monit_conf.d_telegraf dest=/etc/monit/conf.d/telegraf
  103. notify: restart monit
  104. when: telegraf_config_file.stat.exists == True
  105. - name: Copy Mosquitto monit service config files into place
  106. copy: src=etc_monit_conf.d_mosquitto dest=/etc/monit/conf.d/mosquitto
  107. notify: restart monit
  108. when: mosquitto_config_file.stat.exists == True
  109. - name: Copy OpenVPN monit service config files into place
  110. copy: src=etc_monit_conf.d_openvpn dest=/etc/monit/conf.d/openvpn
  111. notify: restart monit
  112. when: openvpn_config_file.stat.exists == True
  113. - name: Copy dnsmasq monit service config files into place
  114. copy: src=etc_monit_conf.d_dnsmasq dest=/etc/monit/conf.d/dnsmasq
  115. notify: restart monit
  116. when: openvpn_config_file.stat.exists == True
  117. - name: Copy monit service config files into place
  118. copy: src=etc_monit_conf.d_{{ item }} dest=/etc/monit/conf.d/{{ item }}
  119. with_items:
  120. - apache2
  121. - dovecot
  122. - pgsql
  123. - postfix
  124. - sshd
  125. - tomcat
  126. notify: restart monit
  127. # TODO add to fail2ban when monit_page_public == 1
  128. - name: Create the Apache monit sites config files
  129. template:
  130. src=etc_apache2_sites-available_monit.j2
  131. dest=/etc/apache2/sites-available/monit_{{ item.name }}.conf
  132. owner=root
  133. group=root
  134. with_items: "{{ virtual_domains }}"
  135. when: monit_page_public == 1
  136. - name: Enable Apache sites (creates new sites-enabled symlinks)
  137. command: a2ensite monit_{{ item }}.conf creates=/etc/apache2/sites-enabled/monit_{{ item }}.conf
  138. notify: restart apache
  139. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  140. when: monit_page_public == 1