add monit service role

This commit is contained in:
ace 2022-01-28 12:16:58 +03:00
commit 54f3fd9ec8
No known key found for this signature in database
GPG Key ID: 2E47CC17BA7F8CF0
5 changed files with 59 additions and 0 deletions

15
README.md Normal file
View File

@ -0,0 +1,15 @@
Setup monit service
monit:
configs:
- name: bird
data: |
check process radosgw
matching "radosgw"
if does not exist for 1 cycles then exec "/usr/bin/systemctl stop bird"
check process nginx
matching "nginx"
if does not exist for 1 cycles then exec "/usr/bin/systemctl stop bird"
check_interval: "1"

2
defaults/main.yaml Normal file
View File

@ -0,0 +1,2 @@
---
monit_version: 5.26.0

6
handlers/main.yaml Normal file
View File

@ -0,0 +1,6 @@
---
- name: Reload monit
systemd:
name: monit
state: reloaded
when: not monit_setup.changed

7
meta/main.yaml Normal file
View File

@ -0,0 +1,7 @@
---
galaxy_info:
description: Monit
galaxy_tags:
- monit
dependencies: []

29
tasks/main.yaml Normal file
View File

@ -0,0 +1,29 @@
---
- name: Install EPEL repository
yum:
package: epel-release
state: latest
- name: Ensure monit {{ monit_version }} installed
yum:
package:
name: monit-{{ monit_version }}
state: present
register: monit_setup
- name: Propagate configs
copy:
content: "{{ item.config }}"
dest: "/etc/monit.d/{{ item.conf_name }}"
notify: Reload monit
with_items:
- "{{ monit_configs }}"
when:
- (monit_configs is defined or monit_configs | length != 0)
- name: Ensure monit enabled and started
systemd:
name: monit
state: started
enabled: yes
daemon_reload: yes