Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_rest/tasks/json_string.yml

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2017, Dag Wieers (@dagwieers) <[email protected]>
3
4 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6
7 # CLEAN ENVIRONMENT
8 - name: Remove tenant
9 cisco.aci.aci_rest: &tenant_absent
10 host: '{{ aci_hostname }}'
11 username: '{{ aci_username }}'
12 password: '{{ aci_password }}'
13 validate_certs: '{{ aci_validate_certs | default(false) }}'
14 use_ssl: '{{ aci_use_ssl | default(true) }}'
15 use_proxy: '{{ aci_use_proxy | default(true) }}'
16 output_level: '{{ aci_output_level | default("info") }}'
17 path: /api/mo/uni/tn-[ansible_test].json
18 method: delete
19
20 - name: Remove tenant 2
21 cisco.aci.aci_rest:
22 <<: *tenant_absent
23 path: /api/mo/uni/tn-[ansible_test_2].json
24
25 # ADD TENANT
26 - name: Add tenant (check mode)
27 cisco.aci.aci_rest: &tenant_present
28 host: '{{ aci_hostname }}'
29 username: '{{ aci_username }}'
30 password: '{{ aci_password }}'
31 validate_certs: '{{ aci_validate_certs | default(false) }}'
32 use_ssl: '{{ aci_use_ssl | default(true) }}'
33 use_proxy: '{{ aci_use_proxy | default(true) }}'
34 output_level: '{{ aci_output_level | default("info") }}'
35 path: /api/mo/uni.json
36 method: post
37 content: |
38 {
39 "fvTenant": {
40 "attributes": {
41 "name": "ansible_test"
42 }
43 }
44 }
45 output_path: "/tmp/ansible_output_file.log"
46 register: cm_add_tenant
47 check_mode: true
48
49 - name: Verify checkmode did not create tenant
50 cisco.aci.aci_tenant:
51 host: '{{ aci_hostname }}'
52 username: '{{ aci_username }}'
53 password: '{{ aci_password }}'
54 validate_certs: '{{ aci_validate_certs | default(false) }}'
55 use_ssl: '{{ aci_use_ssl | default(true) }}'
56 use_proxy: '{{ aci_use_proxy | default(true) }}'
57 output_level: '{{ aci_output_level | default("info") }}'
58 name: ansible_test
59 state: query
60 register: cm_verify_checkmode_tenant
61
62 - name: Verify checkmode POST operation
63 ansible.builtin.assert:
64 that:
65 - cm_add_tenant is changed
66 - cm_add_tenant.proposed.fvTenant.attributes.name == "ansible_test"
67 - cm_add_tenant.proposed.fvTenant.attributes.annotation == "orchestrator:ansible"
68 - cm_verify_checkmode_tenant.current == []
69
70 - name: Add tenant (normal mode)
71 cisco.aci.aci_rest: *tenant_present
72 register: nm_add_tenant
73
74 - name: Add tenant again (normal mode)
75 cisco.aci.aci_rest: *tenant_present
76 register: nm_add_tenant_again
77
78 - name: Verify add_tenant
79 ansible.builtin.assert:
80 that:
81 - nm_add_tenant is changed
82 - nm_add_tenant.imdata.0.fvTenant.attributes.annotation == "orchestrator:ansible"
83 - nm_add_tenant_again is not changed
84
85 # CHANGE TENANT
86 - name: Change description of tenant (normal mode)
87 cisco.aci.aci_rest: &tenant_changed
88 host: '{{ aci_hostname }}'
89 username: '{{ aci_username }}'
90 password: '{{ aci_password }}'
91 validate_certs: '{{ aci_validate_certs | default(false) }}'
92 use_ssl: '{{ aci_use_ssl | default(true) }}'
93 use_proxy: '{{ aci_use_proxy | default(true) }}'
94 output_level: '{{ aci_output_level | default("info") }}'
95 path: /api/mo/uni.json
96 method: post
97 content: |
98 {
99 "fvTenant": {
100 "attributes": {
101 "descr": "Ansible test tenant",
102 "name": "ansible_test"
103 }
104 }
105 }
106 register: nm_add_tenant_descr
107
108 - name: Change description of tenant again (normal mode)
109 cisco.aci.aci_rest: *tenant_changed
110 register: nm_add_tenant_descr_again
111
112 - name: Verify add_tenant_descr
113 ansible.builtin.assert:
114 that:
115 - nm_add_tenant_descr is changed
116 - nm_add_tenant_descr_again is not changed
117
118 # ADD TENANT AGAIN
119 - name: Add tenant again with no description (normal mode)
120 cisco.aci.aci_rest: *tenant_present
121 register: nm_add_tenant_again_no_descr
122
123 - name: Verify add_tenant_again_no_descr
124 ansible.builtin.assert:
125 that:
126 - nm_add_tenant_again_no_descr is not changed
127
128 # QUERY ALL TENANTS
129 - name: Query all tenants (normal mode)
130 cisco.aci.aci_rest: &tenant_query_all
131 host: '{{ aci_hostname }}'
132 username: '{{ aci_username }}'
133 password: '{{ aci_password }}'
134 validate_certs: '{{ aci_validate_certs | default(false) }}'
135 use_ssl: '{{ aci_use_ssl | default(true) }}'
136 use_proxy: '{{ aci_use_proxy | default(true) }}'
137 output_level: '{{ aci_output_level | default("info") }}'
138 path: /api/mo/uni/tn-[ansible_test].json
139 method: get
140 register: nm_query_all_tenants
141
142 - name: Verify query_all_tenants
143 ansible.builtin.assert:
144 that:
145 - nm_query_all_tenants is not changed
146
147
148 # ADD TENANT 2
149 - name: Add tenant 2 (normal mode)
150 cisco.aci.aci_rest:
151 <<: *tenant_present
152 content: |
153 {
154 "fvTenant": {
155 "attributes": {
156 "descr": "Ansible test tenant",
157 "name": "ansible_test_2"
158 }
159 }
160 }
161
162 # QUERY ALL TENANTS WITH PAGINATION
163 - name: Query all tenants with pagination (normal mode)
164 cisco.aci.aci_rest: &tenant_query_all_paginated
165 host: '{{ aci_hostname }}'
166 username: '{{ aci_username }}'
167 password: '{{ aci_password }}'
168 validate_certs: '{{ aci_validate_certs | default(false) }}'
169 use_ssl: '{{ aci_use_ssl | default(true) }}'
170 use_proxy: '{{ aci_use_proxy | default(true) }}'
171 output_level: '{{ aci_output_level | default("info") }}'
172 path: /api/class/uni/fvTenant.json
173 page_size: 10
174 page: 0
175 method: get
176 register: nm_query_all_tenants_paginated
177
178 - name: Query all tenant with pagination - Size 1 / Page 0 (normal mode)
179 cisco.aci.aci_rest:
180 <<: *tenant_query_all_paginated
181 page_size: 1
182 page: 0
183 register: nm_query_all_tenants_paginated_1_0
184
185 - name: Query all tenant with pagination - Size 1 / Page 1 (normal mode)
186 cisco.aci.aci_rest:
187 <<: *tenant_query_all_paginated
188 page_size: 1
189 page: 1
190 register: nm_query_all_tenants_paginated_1_1
191
192 - name: Query all tenant with pagination - Size 2 / Page 0 (normal mode)
193 cisco.aci.aci_rest:
194 <<: *tenant_query_all_paginated
195 page_size: 2
196 page: 0
197 register: nm_query_all_tenants_paginated_2_0
198
199 - name: Verify query_all_tenants_paginated
200 ansible.builtin.assert:
201 that:
202 - nm_query_all_tenants_paginated is not changed
203 - nm_query_all_tenants_paginated_1_0 is not changed
204 - nm_query_all_tenants_paginated_1_1 is not changed
205 - nm_query_all_tenants_paginated_2_0 is not changed
206
207 - name: Verify pagination works as expected
208 ansible.builtin.assert:
209 that:
210 - nm_query_all_tenants_paginated is not changed
211 - nm_query_all_tenants_paginated_1_0.imdata | length == 1
212 - nm_query_all_tenants_paginated_1_1.imdata | length == 1
213 - nm_query_all_tenants_paginated_2_0.imdata | length == 2
214 - nm_query_all_tenants_paginated_1_0.imdata.0.fvTenant.attributes.name == nm_query_all_tenants_paginated_2_0.imdata.0.fvTenant.attributes.name
215 - nm_query_all_tenants_paginated_1_1.imdata.0.fvTenant.attributes.name == nm_query_all_tenants_paginated_2_0.imdata.1.fvTenant.attributes.name
216
217 # QUERY A TENANT
218 - name: Query our tenant
219 cisco.aci.aci_rest: &tenant_query
220 host: '{{ aci_hostname }}'
221 username: '{{ aci_username }}'
222 password: '{{ aci_password }}'
223 validate_certs: '{{ aci_validate_certs | default(false) }}'
224 use_ssl: '{{ aci_use_ssl | default(true) }}'
225 use_proxy: '{{ aci_use_proxy | default(true) }}'
226 output_level: '{{ aci_output_level | default("info") }}'
227 path: /api/mo/uni/tn-[ansible_test].json
228 method: get
229 register: nm_query_tenant
230
231 - name: Verify query_tenant
232 ansible.builtin.assert:
233 that:
234 - nm_query_tenant is not changed
235
236 # REMOVE TENANT
237 - name: Remove tenant (normal mode)
238 cisco.aci.aci_rest: *tenant_absent
239 register: nm_remove_tenant
240
241 - name: Remove tenant again (normal mode)
242 cisco.aci.aci_rest: *tenant_absent
243 register: nm_remove_tenant_again
244
245 - name: Verify remove_tenant
246 ansible.builtin.assert:
247 that:
248 - nm_remove_tenant is changed
249 - nm_remove_tenant_again is not changed
250
251 # QUERY NON-EXISTING TENANT
252 - name: Query non-existing tenant (normal mode)
253 cisco.aci.aci_rest: *tenant_query
254 register: nm_query_non_tenant
255
256 - name: Verify query_non_tenant
257 ansible.builtin.assert:
258 that:
259 - nm_query_non_tenant is not changed
260
261 # VERIFY ANNOTATION SUPPORT
262 - name: Add tenant with annotation option
263 cisco.aci.aci_rest:
264 host: '{{ aci_hostname }}'
265 username: '{{ aci_username }}'
266 password: '{{ aci_password }}'
267 validate_certs: '{{ aci_validate_certs | default(false) }}'
268 use_ssl: '{{ aci_use_ssl | default(true) }}'
269 use_proxy: '{{ aci_use_proxy | default(true) }}'
270 output_level: '{{ aci_output_level | default("info") }}'
271 path: /api/mo/uni.json
272 method: post
273 annotation: test:inoption
274 content: |
275 {
276 "fvTenant": {
277 "attributes": {
278 "descr": "Ansible test tenant",
279 "name": "ansible_test"
280 }
281 }
282 }
283 register: nm_add_tenant_annotation_option
284
285 - name: Add tenant with annotation in content
286 cisco.aci.aci_rest:
287 host: '{{ aci_hostname }}'
288 username: '{{ aci_username }}'
289 password: '{{ aci_password }}'
290 validate_certs: '{{ aci_validate_certs | default(false) }}'
291 use_ssl: '{{ aci_use_ssl | default(true) }}'
292 use_proxy: '{{ aci_use_proxy | default(true) }}'
293 output_level: '{{ aci_output_level | default("info") }}'
294 path: /api/mo/uni.json
295 method: post
296 content: |
297 {
298 "fvTenant": {
299 "attributes": {
300 "descr": "Ansible test tenant",
301 "name": "ansible_test",
302 "annotation": "test:incontent"
303 }
304 }
305 }
306 register: nm_add_tenant_annotation_content
307
308 - name: Add tenant with annotation in content and option
309 cisco.aci.aci_rest:
310 host: '{{ aci_hostname }}'
311 username: '{{ aci_username }}'
312 password: '{{ aci_password }}'
313 validate_certs: '{{ aci_validate_certs | default(false) }}'
314 use_ssl: '{{ aci_use_ssl | default(true) }}'
315 use_proxy: '{{ aci_use_proxy | default(true) }}'
316 output_level: '{{ aci_output_level | default("info") }}'
317 path: /api/mo/uni.json
318 method: post
319 annotation: test:inoption
320 content: |
321 {
322 "fvTenant": {
323 "attributes": {
324 "descr": "Ansible test tenant",
325 "name": "ansible_test",
326 "annotation": "test:optionincontent"
327 }
328 }
329 }
330 register: nm_add_tenant_annotation_option_content
331
332 - name: Add tag to tenant with annotation unsupported
333 cisco.aci.aci_rest:
334 host: '{{ aci_hostname }}'
335 username: '{{ aci_username }}'
336 password: '{{ aci_password }}'
337 validate_certs: '{{ aci_validate_certs | default(false) }}'
338 use_ssl: '{{ aci_use_ssl | default(true) }}'
339 use_proxy: '{{ aci_use_proxy | default(true) }}'
340 output_level: '{{ aci_output_level | default("info") }}'
341 path: /api/mo/uni/tn-ansible_test/tagKey-foo.json
342 method: post
343 annotation: test:inoption
344 content: |
345 {
346 "tagTag": {
347 "attributes": {
348 "value": "bar"
349 }
350 }
351 }
352 register: nm_add_tag_no_annotation
353
354 - name: Remove tenant
355 cisco.aci.aci_rest: *tenant_absent
356
357 - name: Add tenant with children objects including annotation
358 cisco.aci.aci_rest:
359 host: '{{ aci_hostname }}'
360 username: '{{ aci_username }}'
361 password: '{{ aci_password }}'
362 validate_certs: '{{ aci_validate_certs | default(false) }}'
363 use_ssl: '{{ aci_use_ssl | default(true) }}'
364 use_proxy: '{{ aci_use_proxy | default(true) }}'
365 output_level: '{{ aci_output_level | default("info") }}'
366 path: /api/mo/uni.json
367 method: post
368 annotation: test:inoption
369 content: |
370 {
371 "fvTenant": {
372 "attributes": {
373 "descr": "Ansible test tenant",
374 "name": "ansible_test"
375 },
376 "children": [
377 {
378 "fvCtx": {
379 "attributes": {
380 "name": "VRF1"
381 }
382 }
383 },
384 {
385 "fvAp": {
386 "attributes": {
387 "name": "Application1"
388 },
389 "children": [
390 {
391 "fvAEPg": {
392 "attributes": {
393 "name": "WebTier",
394 "annotation": "test:inchild"
395 }
396 }
397 }
398 ]
399 }
400 }
401 ]
402 }
403 }
404 register: nm_add_tenant_annotation_children
405
406 - name: Verify annotation support
407 assert:
408 that:
409 - nm_add_tenant_annotation_option.imdata.0.fvTenant.attributes.annotation == "test:inoption"
410 - nm_add_tenant_annotation_content.imdata.0.fvTenant.attributes.annotation == "test:incontent"
411 - nm_add_tenant_annotation_option_content.imdata.0.fvTenant.attributes.annotation == "test:optionincontent"
412 - nm_add_tag_no_annotation.imdata.0.tagTag.attributes.annotation is undefined
413 - nm_add_tenant_annotation_children.imdata.0.fvTenant.attributes.annotation == "test:inoption"
414 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.attributes.annotation == "test:inoption"
415 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.0.fvAp.children.0.fvAEPg.attributes.annotation == "test:inchild"
416 - nm_add_tenant_annotation_children.imdata.0.fvTenant.children.2.fvCtx.attributes.annotation == "test:inoption"