community.general/tests/integration/targets/monit/tasks/main.yml
2020-10-20 10:34:19 +02:00

73 lines
1.5 KiB
YAML

####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
- block:
- name: Install EPEL repository (RHEL only)
include_role:
name: setup_epel
- name: install monit
become: yes
package:
name: monit
state: present
- include_vars: '{{ item }}'
with_first_found:
- files:
- "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
- '{{ ansible_os_family }}.yml'
- 'defaults.yml'
- name: monit config
become: yes
template:
src: "monitrc.j2"
dest: "{{ monitrc }}"
- name: copy process file
become: yes
copy:
src: "{{item}}"
dest: "/opt/{{item}}"
loop:
- daemon.py
- httpd_echo.py
- name: make monit dir
become: yes
file:
path: "{{ item }}"
state: directory
loop:
- /var/lib/monit
- /var/run/monit
- name: restart monit
become: yes
service:
name: monit
state: restarted
- include_tasks: test.yml
always:
- name: stop monit
become: yes
service:
name: monit
state: stopped
- name: uninstall monit
become: yes
package:
name: monit
state: absent
- name: uninstall EPEL
yum:
name: epel-release
state: absent
when: ansible_facts.distribution in ['RedHat', 'CentOS']