Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/monit/tasks/test_reload_present.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: reload monit when process is missing
7 monit:
8 name: httpd_echo
9 state: reloaded
10 register: result
11
12 - name: check that state is changed
13 assert:
14 that:
15 - result is success
16 - result is changed
17
18 - name: test process not present
19 monit:
20 name: httpd_echo
21 state: present
22 timeout: 5
23 register: result
24 failed_when: result is not skip and result is success
25
26 - name: test monitor missing process
27 monit:
28 name: httpd_echo
29 state: monitored
30 register: result
31 failed_when: result is not skip and result is success
32
33 - name: start process
34 shell: "{{ process_run_cmd }}"
35
36 - import_tasks: check_state.yml
37 vars:
38 reason: verify service running
39 service_state: "up"
40
41 - name: add process config
42 blockinfile:
43 path: "{{ monitrc }}"
44 block: |
45 check process httpd_echo with matching "httpd_echo"
46 start program = "{{ process_run_cmd }}"
47 stop program = "/bin/sh -c 'kill `pgrep -f httpd_echo`'"
48 if failed host localhost port 8082 then restart
49
50 - name: restart monit
51 service:
52 name: monit
53 state: restarted
54
55 - name: wait for monit daemon to be responsive after restart
56 command: monit status -B httpd_echo
57 register: monit_status_check
58 changed_when: false
59 until: monit_status_check.rc == 0
60 retries: 10
61 delay: 0.5
62
63 - name: test process present again
64 monit:
65 name: httpd_echo
66 state: present
67 register: result
68
69 - name: check that state is unchanged
70 assert:
71 that:
72 - result is success
73 - result is not changed