Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/consul/tasks/consul_agent_check.yml

raw
1 ---
2 # Copyright (c) 2024, Michael Ilg (@Ilgmi)
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: Create a service
7 community.general.consul_agent_service:
8 name: nginx
9 service_port: 80
10 address: localhost
11 tags:
12 - http
13 meta:
14 nginx_version: 1.25.3
15 register: result
16
17 - set_fact:
18 nginx_service: "{{result.service}}"
19
20 - assert:
21 that:
22 - result is changed
23 - result.service.ID is defined
24
25 - name: Add a check for service
26 community.general.consul_agent_check:
27 name: nginx_check
28 id: nginx_check
29 interval: 30s
30 http: http://localhost:80/morestatus
31 notes: "Nginx Check"
32 service_id: "{{ nginx_service.ID }}"
33 register: result
34
35 - assert:
36 that:
37 - result is changed
38 - result.check is defined
39 - result.check.CheckID == 'nginx_check'
40 - result.check.ServiceID == 'nginx'
41 - result.check.Interval == '30s'
42 - result.check.Type == 'http'
43 - result.check.Notes == 'Nginx Check'
44
45 - set_fact:
46 nginx_service_check: "{{ result.check }}"
47
48 - name: Update check for service
49 community.general.consul_agent_check:
50 name: "{{ nginx_service_check.Name }}"
51 id: "{{ nginx_service_check.CheckID }}"
52 interval: 60s
53 http: http://localhost:80/morestatus
54 notes: "New Nginx Check"
55 service_id: "{{ nginx_service.ID }}"
56 register: result
57
58 - assert:
59 that:
60 - result is changed
61 - result.check is defined
62 - result.check.CheckID == 'nginx_check'
63 - result.check.ServiceID == 'nginx'
64 - result.check.Interval == '1m0s'
65 - result.check.Type == 'http'
66 - result.check.Notes == 'New Nginx Check'
67
68 - name: Remove check
69 community.general.consul_agent_check:
70 id: "{{ nginx_service_check.Name }}"
71 state: absent
72 service_id: "{{ nginx_service.ID }}"
73 register: result
74
75 - assert:
76 that:
77 - result is changed
78 - result is not failed
79 - result.operation == 'remove'
80
81 - name: Add a check
82 community.general.consul_agent_check:
83 name: check
84 id: check
85 interval: 30s
86 tcp: localhost:80
87 notes: "check"
88 register: result
89
90 - assert:
91 that:
92 - result is changed
93 - result.check is defined
94
95 - name: Update a check
96 community.general.consul_agent_check:
97 name: check
98 id: check
99 interval: 60s
100 tcp: localhost:80
101 notes: "check"
102 register: result
103
104 - assert:
105 that:
106 - result is changed
107 - result.check is defined
108 - result.check.Interval == '1m0s'
109
110 - name: Remove check
111 community.general.consul_agent_check:
112 id: check
113 state: absent
114 register: result