Skip to content

Commit

Permalink
Add support for RedHat deployments (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisRayM authored Mar 4, 2022
1 parent 5b44b47 commit 1841644
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 5 deletions.
10 changes: 8 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
---
- include_vars: redhat.yml
when: ansible_facts["os_family"] == "RedHat"

- include_vars: ubuntu.yml
when: ansible_facts["os_family"] == "Debian"

- include_tasks: setup.yml
when: monit_setup_mode

- name: Copy monit config files
template:
src: "templates/etc/monit/conf.d/{{ item }}"
dest: "/etc/monit/conf.d/{{ item }}"
dest: "{{ monit_includes }}/{{ item }}"
mode: 0644
with_items: "{{ monit_scripts }}"
notify:
Expand All @@ -15,7 +21,7 @@
- name: Copy monit template config files
template:
src: "templates/etc/monit/conf.d/{{ item }}"
dest: "/etc/monit/conf.d/{{ item }}-{{ service_name }}"
dest: "{{ monit_includes }}/{{ item }}-{{ service_name }}"
mode: 0644
with_items: "{{ monit_template_scripts }}"
notify:
Expand Down
23 changes: 23 additions & 0 deletions tasks/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Add epel-release (CentOS)
yum:
name: epel-release
state: latest
when: ansible_distribution == 'CentOS'

- name: Add RPM Key
rpm_key:
key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-{{ ansible_distribution_major_version }}
when: ansible_distribution == 'RedHat'

- name: Add epel-release (RedHat)
yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
state: latest
when: ansible_distribution == 'RedHat'

- name: Install Monit (RedHat)
yum:
name: monit
state: latest

16 changes: 13 additions & 3 deletions tasks/setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,34 @@
- include_tasks: ubuntu.yml
when: ansible_distribution == 'Ubuntu'

- include_tasks: redhat.yml
when: ansible_facts['os_family'] == "RedHat"

- include_vars: redhat.yml
when: ansible_facts["os_family"] == "RedHat"

- include_vars: ubuntu.yml
when: ansible_facts["os_family"] == "Debian"

- name: Copy monitrc configuration file
template:
src: "templates/etc/monit/monitrc.j2"
dest: "/etc/monit/monitrc"
dest: "{{ monit_configuration_path }}"
mode: 0600
notify:
- restart monit

- name: Delete monit config files directory
file:
path: /etc/monit/conf.d
path: "{{ monit_includes }}"
state: absent
ignore_errors: yes
notify:
- restart monit

- name: Create monit config files directory
file:
path: /etc/monit/conf.d
path: "{{ monit_includes }}"
state: directory
mode: 0755
owner: root
Expand Down Expand Up @@ -50,4 +59,5 @@
- name: Enable the Monit service
service:
name: monit
state: started
enabled: yes
1 change: 1 addition & 0 deletions tasks/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
- { package: monit, version: "{{ monit_version }}"}
notify:
- restart monit

3 changes: 3 additions & 0 deletions vars/redhat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
monit_includes: "/etc/monit.d"
monit_configuration_path: "/etc/monitrc"
3 changes: 3 additions & 0 deletions vars/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
monit_includes: "/etc/monit/conf.d"
monit_configuration_path: "/etc/monit/monitrc"

0 comments on commit 1841644

Please sign in to comment.