2019-02-03 00:37:14 +00:00
|
|
|
- name: Install 'monit' package
|
2017-12-08 10:15:38 +00:00
|
|
|
package:
|
|
|
|
name: monit
|
|
|
|
state: present
|
2020-01-14 01:41:03 +00:00
|
|
|
#tags: download
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-31 06:36:30 +00:00
|
|
|
- name: Install chkconfig package (debian-8)
|
2017-12-08 10:15:38 +00:00
|
|
|
package:
|
|
|
|
name: chkconfig
|
|
|
|
state: present
|
2017-07-04 20:27:44 +00:00
|
|
|
when: is_debian and ansible_distribution_major_version == "8"
|
2020-01-14 01:41:03 +00:00
|
|
|
#tags: download
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2018-10-31 06:36:30 +00:00
|
|
|
- name: Install /etc/monitrc from template
|
2017-12-08 10:15:38 +00:00
|
|
|
template:
|
|
|
|
backup: yes
|
|
|
|
src: monitrc
|
|
|
|
dest: /etc/monitrc
|
|
|
|
owner: root
|
|
|
|
group: root
|
2020-01-14 01:41:03 +00:00
|
|
|
mode: '0600'
|
2017-05-27 18:09:50 +00:00
|
|
|
|
2019-07-08 11:22:23 +00:00
|
|
|
# - name: Install config file /etc/monit.d/watchdog from template (NEVER RUNS, WHY?)
|
|
|
|
# template:
|
|
|
|
# src: watchdog
|
|
|
|
# dest: /etc/monit.d/watchdog
|
|
|
|
# owner: root
|
|
|
|
# group: root
|
|
|
|
# force: yes
|
2020-01-14 01:41:03 +00:00
|
|
|
# mode: '0755'
|
2019-07-08 11:22:23 +00:00
|
|
|
# register: monit_config
|
|
|
|
# when: False # IS THIS A BUG ?
|
|
|
|
# until: monit_config | success
|
|
|
|
# retries: 5
|
|
|
|
# delay: 1
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
#TODO: create systemd script
|
2018-10-31 06:36:30 +00:00
|
|
|
- name: Enable 'monit' service (chkconfig monit on)
|
2017-05-27 18:09:50 +00:00
|
|
|
command: chkconfig monit on
|
2017-07-04 20:27:44 +00:00
|
|
|
when: is_debian and ansible_local.local_facts.os_ver == "debian-8"
|
2017-05-27 18:09:50 +00:00
|
|
|
|
|
|
|
#- name: Restart monit service
|
|
|
|
# command: service monit restart
|
|
|
|
|
2018-10-31 06:36:30 +00:00
|
|
|
- name: Add 'monit' variable values to {{ iiab_ini_file }}
|
2017-12-08 10:15:38 +00:00
|
|
|
ini_file:
|
2018-10-31 06:36:30 +00:00
|
|
|
path: "{{ iiab_ini_file }}"
|
2017-12-08 10:15:38 +00:00
|
|
|
section: monit
|
|
|
|
option: "{{ item.option }}"
|
2020-01-12 02:41:37 +00:00
|
|
|
value: "{{ item.value | string }}"
|
2017-05-27 18:09:50 +00:00
|
|
|
with_items:
|
|
|
|
- option: name
|
2017-12-08 10:15:38 +00:00
|
|
|
value: Monit
|
2017-05-27 18:09:50 +00:00
|
|
|
- option: description
|
2017-10-28 00:56:48 +00:00
|
|
|
value: '"Monit is a background service monitor which can correct problems, send email, restart services."'
|
2017-05-27 18:09:50 +00:00
|
|
|
- option: enabled
|
|
|
|
value: "{{ monit_enabled }}"
|
2020-01-12 22:06:24 +00:00
|
|
|
|
2020-01-12 23:15:33 +00:00
|
|
|
- name: "Add 'monit_installed: True' to {{ iiab_state_file }}"
|
2020-01-12 22:06:24 +00:00
|
|
|
lineinfile:
|
2020-01-12 23:15:33 +00:00
|
|
|
dest: "{{ iiab_state_file }}" # /etc/iiab/iiab_state.yml
|
2020-01-12 22:06:24 +00:00
|
|
|
regexp: '^monit_installed'
|
|
|
|
line: 'monit_installed: True'
|