1---
2- name: setup zone is present
3  cs_zone:
4    name: "{{ cs_resource_prefix }}-zone"
5    dns1: 8.8.8.8
6    dns2: 8.8.4.4
7    network_type: Basic
8  register: zone
9- name: verify setup zone is present
10  assert:
11    that:
12      - zone is successful
13
14- name: setup pod is absent
15  cs_pod:
16    name: "{{ cs_resource_prefix }}-pod"
17    zone: "{{ cs_resource_prefix }}-zone"
18    state: absent
19  register: pod
20- name: verify setup pod is absent
21  assert:
22    that:
23      - pod is successful
24
25- name: test fail if missing name
26  cs_pod:
27    zone: "{{ cs_resource_prefix }}-zone"
28  register: pod
29  ignore_errors: true
30- name: verify results of fail if missing name
31  assert:
32    that:
33      - pod is failed
34      - "pod.msg == 'missing required arguments: name'"
35
36
37- name: test create pod in check mode
38  cs_pod:
39    name: "{{ cs_resource_prefix }}-pod"
40    zone: "{{ cs_resource_prefix }}-zone"
41    start_ip: 10.100.10.101
42    gateway: 10.100.10.1
43    netmask: 255.255.255.0
44  register: pod_origin
45  check_mode: true
46- name: verify test create pod  in check mode
47  assert:
48    that:
49      - pod_origin is changed
50      - pod_origin.zone == "{{ cs_resource_prefix }}-zone"
51
52- name: test create pod
53  cs_pod:
54    name: "{{ cs_resource_prefix }}-pod"
55    zone: "{{ cs_resource_prefix }}-zone"
56    start_ip: 10.100.10.101
57    gateway: 10.100.10.1
58    netmask: 255.255.255.0
59  register: pod_origin
60- name: verify test create pod
61  assert:
62    that:
63      - pod_origin is changed
64      - pod_origin.allocation_state == "Enabled"
65      - pod_origin.start_ip == "10.100.10.101"
66      - pod_origin.end_ip == "10.100.10.254"
67      - pod_origin.gateway == "10.100.10.1"
68      - pod_origin.netmask == "255.255.255.0"
69      - pod_origin.zone == "{{ cs_resource_prefix }}-zone"
70
71- name: test create pod idempotence
72  cs_pod:
73    name: "{{ cs_resource_prefix }}-pod"
74    zone: "{{ cs_resource_prefix }}-zone"
75    start_ip: 10.100.10.101
76    gateway: 10.100.10.1
77    netmask: 255.255.255.0
78  register: pod
79- name: verify test create pod idempotence
80  assert:
81    that:
82      - pod is not changed
83      - pod.allocation_state == "Enabled"
84      - pod.start_ip == "10.100.10.101"
85      - pod.end_ip == "10.100.10.254"
86      - pod.gateway == "10.100.10.1"
87      - pod.netmask == "255.255.255.0"
88      - pod.zone == "{{ cs_resource_prefix }}-zone"
89
90- name: test update pod in check mode
91  cs_pod:
92    name: "{{ cs_resource_prefix }}-pod"
93    zone: "{{ cs_resource_prefix }}-zone"
94    gateway: 10.100.10.2
95    netmask: 255.255.255.0
96  register: pod
97  check_mode: true
98- name: verify test update pod in check mode
99  assert:
100    that:
101      - pod is changed
102      - pod.allocation_state == "Enabled"
103      - pod.start_ip == "10.100.10.101"
104      - pod.end_ip == "10.100.10.254"
105      - pod.gateway == "10.100.10.1"
106      - pod.netmask == "255.255.255.0"
107      - pod.zone == "{{ cs_resource_prefix }}-zone"
108
109- name: test update pod
110  cs_pod:
111    name: "{{ cs_resource_prefix }}-pod"
112    zone: "{{ cs_resource_prefix }}-zone"
113    gateway: 10.100.10.2
114    netmask: 255.255.255.0
115  register: pod
116- name: verify test update pod
117  assert:
118    that:
119      - pod is changed
120      - pod.allocation_state == "Enabled"
121      - pod.start_ip == "10.100.10.101"
122      - pod.end_ip == "10.100.10.254"
123      - pod.gateway == "10.100.10.2"
124      - pod.netmask == "255.255.255.0"
125      - pod.zone == "{{ cs_resource_prefix }}-zone"
126
127- name: test update pod idempotence
128  cs_pod:
129    name: "{{ cs_resource_prefix }}-pod"
130    zone: "{{ cs_resource_prefix }}-zone"
131    gateway: 10.100.10.2
132    netmask: 255.255.255.0
133  register: pod
134- name: verify test update pod idempotence
135  assert:
136    that:
137      - pod is not changed
138      - pod.allocation_state == "Enabled"
139      - pod.start_ip == "10.100.10.101"
140      - pod.end_ip == "10.100.10.254"
141      - pod.gateway == "10.100.10.2"
142      - pod.netmask == "255.255.255.0"
143      - pod.zone == "{{ cs_resource_prefix }}-zone"
144
145- name: test disable pod in check mode
146  cs_pod:
147    name: "{{ cs_resource_prefix }}-pod"
148    zone: "{{ cs_resource_prefix }}-zone"
149    state: disabled
150  register: pod
151  check_mode: true
152- name: verify test enable pod in check mode
153  assert:
154    that:
155      - pod is changed
156      - pod.allocation_state == "Enabled"
157      - pod.id == pod_origin.id
158      - pod.start_ip == "10.100.10.101"
159      - pod.end_ip == "10.100.10.254"
160      - pod.gateway == "10.100.10.2"
161      - pod.netmask == "255.255.255.0"
162      - pod.zone == "{{ cs_resource_prefix }}-zone"
163
164- name: test disable pod
165  cs_pod:
166    name: "{{ cs_resource_prefix }}-pod"
167    zone: "{{ cs_resource_prefix }}-zone"
168    state: disabled
169  register: pod
170- name: verify test enable pod
171  assert:
172    that:
173      - pod is changed
174      - pod.allocation_state == "Disabled"
175      - pod.id == pod_origin.id
176      - pod.start_ip == "10.100.10.101"
177      - pod.end_ip == "10.100.10.254"
178      - pod.gateway == "10.100.10.2"
179      - pod.netmask == "255.255.255.0"
180      - pod.zone == "{{ cs_resource_prefix }}-zone"
181
182- name: test disable pod idempotence
183  cs_pod:
184    name: "{{ cs_resource_prefix }}-pod"
185    zone: "{{ cs_resource_prefix }}-zone"
186    state: disabled
187  register: pod
188- name: verify test enable pod idempotence
189  assert:
190    that:
191      - pod is not changed
192      - pod.allocation_state == "Disabled"
193      - pod.id == pod_origin.id
194      - pod.start_ip == "10.100.10.101"
195      - pod.end_ip == "10.100.10.254"
196      - pod.gateway == "10.100.10.2"
197      - pod.netmask == "255.255.255.0"
198      - pod.zone == "{{ cs_resource_prefix }}-zone"
199
200- name: test enable pod in check mode
201  cs_pod:
202    name: "{{ cs_resource_prefix }}-pod"
203    zone: "{{ cs_resource_prefix }}-zone"
204    state: enabled
205  register: pod
206  check_mode: true
207- name: verify test disable pod in check mode
208  assert:
209    that:
210      - pod is changed
211      - pod.allocation_state == "Disabled"
212      - pod.id == pod_origin.id
213      - pod.start_ip == "10.100.10.101"
214      - pod.end_ip == "10.100.10.254"
215      - pod.gateway == "10.100.10.2"
216      - pod.netmask == "255.255.255.0"
217      - pod.zone == "{{ cs_resource_prefix }}-zone"
218
219- name: test enable pod
220  cs_pod:
221    name: "{{ cs_resource_prefix }}-pod"
222    zone: "{{ cs_resource_prefix }}-zone"
223    state: enabled
224  register: pod
225- name: verify test disable pod
226  assert:
227    that:
228      - pod is changed
229      - pod.allocation_state == "Enabled"
230      - pod.id == pod_origin.id
231      - pod.start_ip == "10.100.10.101"
232      - pod.end_ip == "10.100.10.254"
233      - pod.gateway == "10.100.10.2"
234      - pod.netmask == "255.255.255.0"
235      - pod.zone == "{{ cs_resource_prefix }}-zone"
236
237
238- name: test enable pod idempotence
239  cs_pod:
240    name: "{{ cs_resource_prefix }}-pod"
241    zone: "{{ cs_resource_prefix }}-zone"
242    state: enabled
243  register: pod
244- name: verify test enabled pod idempotence
245  assert:
246    that:
247      - pod is not changed
248      - pod.allocation_state == "Enabled"
249      - pod.id == pod_origin.id
250      - pod.start_ip == "10.100.10.101"
251      - pod.end_ip == "10.100.10.254"
252      - pod.gateway == "10.100.10.2"
253      - pod.netmask == "255.255.255.0"
254      - pod.zone == "{{ cs_resource_prefix }}-zone"
255
256- name: test absent pod in check mode
257  cs_pod:
258    name: "{{ cs_resource_prefix }}-pod"
259    zone: "{{ cs_resource_prefix }}-zone"
260    state: absent
261  register: pod
262  check_mode: true
263- name: verify test create pod in check mode
264  assert:
265    that:
266      - pod is changed
267      - pod.id == pod_origin.id
268      - pod.allocation_state == "Enabled"
269      - pod.start_ip == "10.100.10.101"
270      - pod.end_ip == "10.100.10.254"
271      - pod.gateway == "10.100.10.2"
272      - pod.netmask == "255.255.255.0"
273      - pod.zone == "{{ cs_resource_prefix }}-zone"
274
275- name: test absent pod
276  cs_pod:
277    name: "{{ cs_resource_prefix }}-pod"
278    zone: "{{ cs_resource_prefix }}-zone"
279    state: absent
280  register: pod
281- name: verify test create pod
282  assert:
283    that:
284      - pod is changed
285      - pod.id == pod_origin.id
286      - pod.allocation_state == "Enabled"
287      - pod.start_ip == "10.100.10.101"
288      - pod.end_ip == "10.100.10.254"
289      - pod.gateway == "10.100.10.2"
290      - pod.netmask == "255.255.255.0"
291      - pod.zone == "{{ cs_resource_prefix }}-zone"
292
293- name: test absent pod idempotence
294  cs_pod:
295    name: "{{ cs_resource_prefix }}-pod"
296    zone: "{{ cs_resource_prefix }}-zone"
297    state: absent
298  register: pod
299- name: verify test absent pod idempotence
300  assert:
301    that:
302      - pod is not changed
303