2022-08-05 21:31:34 +02:00
|
|
|
---
|
2020-10-23 12:26:23 +02:00
|
|
|
####################################################################
|
|
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
|
|
####################################################################
|
|
|
|
|
2022-08-05 21:31:34 +02:00
|
|
|
# Copyright (c) Ansible Project
|
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2020-10-23 12:26:23 +02:00
|
|
|
- block:
|
|
|
|
- name: Install EPEL repository (RHEL only)
|
|
|
|
include_role:
|
|
|
|
name: setup_epel
|
2022-05-22 17:20:30 +02:00
|
|
|
when:
|
|
|
|
- ansible_distribution in ['RedHat', 'CentOS']
|
|
|
|
- ansible_distribution_major_version is version('9', '<')
|
2020-10-23 12:26:23 +02:00
|
|
|
|
|
|
|
- name: create required directories
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
loop:
|
|
|
|
- /var/lib/monit
|
|
|
|
- /var/run/monit
|
|
|
|
- "{{ process_root }}"
|
|
|
|
|
|
|
|
- name: install monit
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
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
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
template:
|
|
|
|
src: "monitrc.j2"
|
|
|
|
dest: "{{ monitrc }}"
|
|
|
|
|
|
|
|
- name: copy process file
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
copy:
|
|
|
|
src: httpd_echo.py
|
|
|
|
dest: "{{ process_file }}"
|
|
|
|
|
2022-08-13 12:08:07 +02:00
|
|
|
- name: Install virtualenv on CentOS 8
|
2022-04-01 22:53:05 +02:00
|
|
|
package:
|
|
|
|
name: virtualenv
|
|
|
|
state: present
|
|
|
|
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '8'
|
|
|
|
|
2022-08-13 12:08:07 +02:00
|
|
|
- name: Install virtualenv on Arch Linux
|
|
|
|
pip:
|
|
|
|
name: virtualenv
|
2022-04-01 22:53:05 +02:00
|
|
|
state: present
|
|
|
|
when: ansible_os_family == 'Archlinux'
|
|
|
|
|
2020-10-23 12:26:23 +02:00
|
|
|
- name: install dependencies
|
|
|
|
pip:
|
|
|
|
name: "{{ item }}"
|
|
|
|
virtualenv: "{{ process_venv }}"
|
2022-07-23 12:02:18 +02:00
|
|
|
extra_args: "-c {{ remote_constraints }}"
|
2020-10-23 12:26:23 +02:00
|
|
|
loop:
|
|
|
|
- setuptools==44
|
|
|
|
- python-daemon
|
|
|
|
|
|
|
|
- name: restart monit
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
service:
|
|
|
|
name: monit
|
|
|
|
state: restarted
|
|
|
|
|
|
|
|
- include_tasks: test.yml
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: stop monit
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
service:
|
|
|
|
name: monit
|
|
|
|
state: stopped
|
|
|
|
|
|
|
|
- name: uninstall monit
|
2023-02-15 22:55:23 +01:00
|
|
|
become: true
|
2020-10-23 12:26:23 +02:00
|
|
|
package:
|
|
|
|
name: monit
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: remove process files
|
|
|
|
file:
|
|
|
|
path: "{{ process_root }}"
|
|
|
|
state: absent
|