Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_l3out/tasks/main.yml

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2023, Gaspard Micol (@gmicol) <[email protected]>
3 # Copyright: (c) 2023, Akini Ross (@akinross) <[email protected]>
4
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 - name: Test that we have an ACI APIC host, ACI username and ACI password
8 ansible.builtin.fail:
9 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
10 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
11
12 - name: Set vars
13 ansible.builtin.set_fact:
14 aci_info: &aci_info
15 host: "{{ aci_hostname }}"
16 username: "{{ aci_username }}"
17 password: "{{ aci_password }}"
18 validate_certs: '{{ aci_validate_certs | default(false) }}'
19 use_ssl: '{{ aci_use_ssl | default(true) }}'
20 use_proxy: '{{ aci_use_proxy | default(true) }}'
21 output_level: debug
22
23 - name: Query system information
24 cisco.aci.aci_system:
25 <<: *aci_info
26 id: 1
27 state: query
28 register: version
29
30 # CLEAN ENVIRONMENT
31 - name: Remove the ansible_tenant
32 cisco.aci.aci_tenant:
33 <<: *aci_info
34 tenant: ansible_tenant
35 state: absent
36
37 - name: Verify Cloud and Non-Cloud Sites in use.
38 ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
39
40 - name: Execute tasks only for non-cloud sites
41 when: query_cloud.current == [] # This condition will execute only non-cloud sites
42 block: # block specifies execution of tasks within, based on conditions
43 - name: Add a new tenant
44 cisco.aci.aci_tenant:
45 <<: *aci_info
46 tenant: ansible_tenant
47 description: Ansible tenant
48 state: present
49
50 - name: Remove the ansible_l3out
51 cisco.aci.aci_l3out: &aci_l3out_absent
52 <<: *aci_info
53 tenant: ansible_tenant
54 name: ansible_l3out
55 description: L3Out for ansible_tenant tenant
56 domain: ansible_dom
57 vrf: ansible_vrf
58 state: absent
59
60 - name: Remove the second ansible_l3out
61 cisco.aci.aci_l3out: &aci_l3out_2_absent
62 <<: *aci_info
63 tenant: ansible_tenant
64 name: ansible_l3out_2
65 description: Second L3Out
66 domain: ansible_dom
67 vrf: ansible_vrf
68 l3protocol: [ ospf, bgp ]
69 state: absent
70
71 - name: Add a new L3Out (check_mode)
72 cisco.aci.aci_l3out: &aci_l3out_present
73 <<: *aci_l3out_absent
74 state: present
75 check_mode: true
76 register: cm_add_l3out
77
78 - name: Add a new L3Out (normal_mode)
79 cisco.aci.aci_l3out:
80 <<: *aci_l3out_present
81 register: nm_add_l3out
82
83 - name: create L3Out again - testing idempotency
84 cisco.aci.aci_l3out:
85 <<: *aci_l3out_present
86 register: create_idempotency
87
88 - name: Add the second ansible_l3out
89 cisco.aci.aci_l3out:
90 <<: *aci_l3out_2_absent
91 state: present
92 register: cm_add_l3out_2
93
94 - name: asserts for l3out creation tasks
95 ansible.builtin.assert:
96 that:
97 - cm_add_l3out is changed
98 - cm_add_l3out.previous == []
99 - cm_add_l3out.current == []
100 - nm_add_l3out is changed
101 - nm_add_l3out.current.0.l3extOut.attributes.descr == cm_add_l3out.sent.l3extOut.attributes.descr == "L3Out for ansible_tenant tenant"
102 - nm_add_l3out.current.0.l3extOut.attributes.name == cm_add_l3out.sent.l3extOut.attributes.name == "ansible_l3out"
103 - create_idempotency is not changed
104
105 - name: Add export and import to route_control
106 cisco.aci.aci_l3out:
107 <<: *aci_l3out_present
108 route_control: [ import, export ]
109 register: nm_add_l3out_import_export
110
111 - name: Add export to route_control
112 cisco.aci.aci_l3out:
113 <<: *aci_l3out_present
114 route_control: export
115 register: nm_add_l3out_export
116
117 - name: Add just import to route_control - testing failure message
118 cisco.aci.aci_l3out:
119 <<: *aci_l3out_present
120 route_control: import
121 register: nm_add_l3out_import_error
122 ignore_errors: true
123
124 - name: asserts for l3out route control tasks
125 ansible.builtin.assert:
126 that:
127 - nm_add_l3out_import_export is changed
128 - nm_add_l3out_import_export.current.0.l3extOut.attributes.enforceRtctrl == "export,import"
129 - nm_add_l3out_export is changed
130 - nm_add_l3out_export.current.0.l3extOut.attributes.enforceRtctrl == "export"
131 - nm_add_l3out_import_error.msg == "The route_control parameter is invalid{{':'}} allowed options are export or import,export only"
132
133 - name: Add BGP protocol
134 cisco.aci.aci_l3out:
135 <<: *aci_l3out_present
136 l3protocol: bgp
137 register: nm_add_l3out_bgp
138
139 - name: Add BGP protocol again - testing L3protocol changes
140 cisco.aci.aci_l3out:
141 <<: *aci_l3out_present
142 l3protocol: bgp
143 register: nm_add_l3out_bgp_again
144
145 - name: Remove OSPF protocol - testing L3protocol changes
146 cisco.aci.aci_l3out: &aci_l3out_remove_ospf
147 <<: *aci_l3out_2_absent
148 l3protocol: [ eigrp, pim ]
149 asn: 1
150 state: present
151 register: nm_add_l3out_bgp_without_ospf
152
153 - name: Remove OSPF protocol again - testing L3protocol changes
154 cisco.aci.aci_l3out:
155 <<: *aci_l3out_remove_ospf
156 register: nm_add_l3out_bgp_without_ospf_again
157
158 - name: Add PIM protocol, ospf_spec and asn - testing warning message for asn
159 aci_l3out: &aci_l3out_add_pim
160 <<: *aci_l3out_present
161 l3protocol: pim
162 asn: 1
163 register: nm_add_l3out_pim
164
165 - name: Add PIM protocol, ospf_spec and asn again - testing warning message for asn
166 aci_l3out:
167 <<: *aci_l3out_add_pim
168 register: nm_add_l3out_pim_again
169
170 - name: Add EIGRP protocol - testing warning message for OSPF spec
171 cisco.aci.aci_l3out: &aci_l3out_add_eigrp
172 <<: *aci_l3out_present
173 l3protocol: eigrp
174 asn: 1
175 ospf:
176 description: OSPF warnings message works
177 register: nm_add_l3out_eigrp
178
179 - name: Add EIGRP protocol again - testing warning message for OSPF spec
180 aci_l3out:
181 <<: *aci_l3out_add_eigrp
182 register: nm_add_l3out_eigrp_again
183
184 - name: remove asn - testing failure message
185 cisco.aci.aci_l3out:
186 <<: *aci_l3out_present
187 l3protocol: eigrp
188 asn: null
189 register: add_l3out_without_asn
190 ignore_errors: true
191
192 - name: remove protocol - testing static protocol
193 cisco.aci.aci_l3out:
194 <<: *aci_l3out_present
195 l3protocol: static
196 register: nm_remove_l3protocol
197
198 - name: asserts for l3out protocols tasks
199 ansible.builtin.assert:
200 that:
201 - nm_add_l3out_bgp is changed
202 - nm_add_l3out_bgp_again is not changed
203 - nm_add_l3out_bgp_without_ospf is changed
204 - nm_add_l3out_bgp_without_ospf_again is not changed
205 - nm_add_l3out_pim is changed
206 - nm_add_l3out_pim.warnings.0 == "Parameter 'asn' is only applicable when l3protocol is 'eigrp'. The ASN will be ignored"
207 - nm_add_l3out_pim_again is not changed
208 - nm_add_l3out_eigrp is changed
209 - nm_add_l3out_eigrp.current.0.l3extOut.children.0.eigrpExtP.attributes.asn == "1"
210 - nm_add_l3out_eigrp.warnings.0 == "Parameter 'ospf' is only applicable when l3protocol is 'ospf'. The OPSF specifications will be ignored"
211 - nm_add_l3out_eigrp_again is not changed
212 - add_l3out_without_asn.msg == "Parameter 'asn' is required when l3protocol is 'eigrp'"
213 - nm_remove_l3protocol is changed
214
215 - name: Add OSPF protocol
216 cisco.aci.aci_l3out:
217 <<: *aci_l3out_present
218 l3protocol: ospf
219 ospf:
220 area_cost: 1
221 area_ctrl: [ summary, redistribute ]
222 area_id: 0.0.0.2
223 area_type: regular
224 multipod_internal: no
225 description: test for ospf protocol
226 register: nm_add_l3out_ospf
227
228 - name: asserts for l3out OSPF protocol tasks
229 ansible.builtin.assert:
230 that:
231 - nm_add_l3out_ospf is changed
232 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.areaCost == "1"
233 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.areaCtrl == "redistribute,summary"
234 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.areaId == "0.0.0.2"
235 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.areaType == "regular"
236 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.descr == "test for ospf protocol"
237 - nm_add_l3out_ospf.current.0.l3extOut.children.2.ospfExtP.attributes.multipodInternal == "no"
238
239 - name: get ansible_l3out
240 cisco.aci.aci_l3out:
241 <<: *aci_l3out_present
242 state: query
243 register: get_l3out
244
245 - name: get all l3outs in ansible_tenant
246 cisco.aci.aci_l3out:
247 <<: *aci_info
248 tenant: ansible_tenant
249 state: query
250 register: get_all_l3out_ansible_tenant
251
252 - name: get all l3outs
253 cisco.aci.aci_l3out:
254 <<: *aci_info
255 state: query
256 register: get_all_l3out
257
258 - name: asserts query tasks
259 ansible.builtin.assert:
260 that:
261 - get_l3out is not changed
262 - '"rsp-subtree=full&rsp-subtree-class=bgpExtP,eigrpExtP,l3extRsEctx,l3extRsL3DomAtt,ospfExtP,pimExtP" in get_l3out.filter_string'
263 - '"tn-ansible_tenant/out-ansible_l3out.json" in get_l3out.url'
264 - get_all_l3out_ansible_tenant is not changed
265 - '"pimExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.0.l3extOut.children.0'
266 - '"eigrpExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.0.l3extOut.children.1'
267 - '"ospfExtP" in get_all_l3out_ansible_tenant.current.0.fvTenant.children.1.l3extOut.children.2'
268 - get_all_l3out is not changed
269 - get_all_l3out.current | length >= 2
270
271 - name: delete l3out (check_mode)
272 cisco.aci.aci_l3out:
273 <<: *aci_l3out_present
274 state: absent
275 check_mode: true
276 register: delete_cm
277
278 - name: delete l3out (normal_mode)
279 cisco.aci.aci_l3out:
280 <<: *aci_l3out_present
281 state: absent
282 register: delete_l3out
283
284 - name: delete l3out again - testing idempotency
285 cisco.aci.aci_l3out:
286 <<: *aci_l3out_present
287 state: absent
288 register: delete_idempotency
289
290 - name: asserts for deletion tasks
291 ansible.builtin.assert:
292 that:
293 - delete_cm is changed
294 - delete_cm.proposed == {}
295 - delete_l3out is changed
296 - delete_l3out.previous != []
297 - delete_l3out.method == "DELETE"
298 - delete_idempotency is not changed
299 - delete_idempotency.previous == []
300
301 - name: Execute tasks only for ACI v5+ because SR-MPLS L3Out is not supported lower versions
302 when: version.current.0.topSystem.attributes.version is version('5', '>=')
303 block:
304
305 - name: Add a SR-MPLS l3out
306 cisco.aci.aci_l3out: &aci_sr_mpls_l3out
307 <<: *aci_info
308 tenant: ansible_tenant
309 name: ansible_sr_mpls_l3out
310 domain: ansible_dom
311 vrf: ansible_vrf
312 mpls: "yes"
313 state: present
314 register: add_sr_mpls_l3out
315
316 - name: Add a SR-MPLS l3out again
317 cisco.aci.aci_l3out:
318 <<: *aci_sr_mpls_l3out
319 register: add_sr_mpls_l3out_again
320
321 - name: Delete a SR-MPLS l3out
322 cisco.aci.aci_l3out:
323 <<: *aci_sr_mpls_l3out
324 state: absent
325 register: delete_sr_mpls_l3out
326
327 - name: Ensure infra SR-MPLS l3out does not exist
328 cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out_absent
329 <<: *aci_info
330 tenant: infra
331 name: ansible_infra_sr_mpls_l3out
332 mpls: "yes"
333 state: absent
334
335 - name: Add a infra SR-MPLS l3out (error)
336 cisco.aci.aci_l3out: &aci_infra_sr_mpls_l3out
337 <<: *aci_info
338 tenant: infra
339 name: ansible_infra_sr_mpls_l3out
340 domain: ansible_dom
341 vrf: ansible_vrf
342 l3protocol: ospf
343 mpls: "yes"
344 ignore_errors: true
345 register: err_infra_sr_mpls_l3out_no_bgp
346
347 - name: Add a infra SR-MPLS l3out (error)
348 cisco.aci.aci_l3out:
349 <<: *aci_infra_sr_mpls_l3out
350 l3protocol: bgp
351 ignore_errors: true
352 register: err_infra_sr_mpls_l3out_no_overlay_1_vrf
353
354 - name: Add a infra SR-MPLS l3out
355 cisco.aci.aci_l3out:
356 <<: *aci_infra_sr_mpls_l3out
357 vrf: overlay-1
358 l3protocol: bgp
359 register: add_infra_sr_mpls_l3out
360
361 - name: Add a infra SR-MPLS l3out again
362 cisco.aci.aci_l3out:
363 <<: *aci_infra_sr_mpls_l3out
364 vrf: overlay-1
365 l3protocol: bgp
366 register: add_infra_sr_mpls_l3out_again
367
368 - name: Delete a infra SR-MPLS l3out
369 cisco.aci.aci_l3out:
370 <<: *aci_infra_sr_mpls_l3out_absent
371 register: delete_infra_sr_mpls_l3out
372
373 - name: Asserts SR-MPLS l3out
374 ansible.builtin.assert:
375 that:
376 - add_sr_mpls_l3out is changed
377 - add_sr_mpls_l3out.previous == []
378 - add_sr_mpls_l3out.current.0.l3extOut.attributes.mplsEnabled == "yes"
379 - add_sr_mpls_l3out.current.0.l3extOut.attributes.name == "ansible_sr_mpls_l3out"
380 - add_sr_mpls_l3out.current.0.l3extOut.children.0.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom"
381 - add_sr_mpls_l3out.current.0.l3extOut.children.1.l3extRsEctx.attributes.tnFvCtxName == "ansible_vrf"
382 - add_sr_mpls_l3out_again is not changed
383 - delete_sr_mpls_l3out is changed
384 - delete_sr_mpls_l3out.previous.0.l3extOut.attributes.mplsEnabled == "yes"
385 - delete_sr_mpls_l3out.previous.0.l3extOut.attributes.name == "ansible_sr_mpls_l3out"
386 - delete_sr_mpls_l3out.previous.0.l3extOut.children.0.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom"
387 - delete_sr_mpls_l3out.previous.0.l3extOut.children.1.l3extRsEctx.attributes.tnFvCtxName == "ansible_vrf"
388 - delete_sr_mpls_l3out.current == []
389 - add_infra_sr_mpls_l3out is changed
390 - add_infra_sr_mpls_l3out.previous == []
391 - add_infra_sr_mpls_l3out.current.0.l3extOut.attributes.mplsEnabled == "yes"
392 - add_infra_sr_mpls_l3out.current.0.l3extOut.attributes.name == "ansible_infra_sr_mpls_l3out"
393 - add_infra_sr_mpls_l3out.current.0.l3extOut.children.0.mplsExtP.children.0.mplsRsLabelPol.attributes.tDn == "uni/tn-infra/mplslabelpol-default"
394 - add_infra_sr_mpls_l3out.current.0.l3extOut.children.1.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom"
395 - add_infra_sr_mpls_l3out.current.0.l3extOut.children.2.l3extProvLbl.attributes.name == "ansible_infra_sr_mpls_l3out"
396 - add_infra_sr_mpls_l3out.current.0.l3extOut.children.3.l3extRsEctx.attributes.tnFvCtxName == "overlay-1"
397 - add_infra_sr_mpls_l3out.current.0.l3extOut.children.4.bgpExtP.attributes.descr == ""
398 - add_infra_sr_mpls_l3out_again is not changed
399 - delete_infra_sr_mpls_l3out is changed
400 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.attributes.mplsEnabled == "yes"
401 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.attributes.name == "ansible_infra_sr_mpls_l3out"
402 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.0.mplsExtP.children.0.mplsRsLabelPol.attributes.tDn == "uni/tn-infra/mplslabelpol-default"
403 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.1.l3extRsL3DomAtt.attributes.tDn == "uni/l3dom-ansible_dom"
404 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.2.l3extProvLbl.attributes.name == "ansible_infra_sr_mpls_l3out"
405 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.3.l3extRsEctx.attributes.tnFvCtxName == "overlay-1"
406 - delete_infra_sr_mpls_l3out.previous.0.l3extOut.children.4.bgpExtP.attributes.descr == ""
407 - delete_infra_sr_mpls_l3out.current == []
408 - err_infra_sr_mpls_l3out_no_overlay_1_vrf.failed == true
409 - err_infra_sr_mpls_l3out_no_overlay_1_vrf.msg == "The vrf parameter must be 'overlay-1' when tenant is 'infra' and mpls is 'yes'"
410 - err_infra_sr_mpls_l3out_no_bgp.failed == true
411 - err_infra_sr_mpls_l3out_no_bgp.msg == "The l3protocol parameter must be 'bgp' when tenant is 'infra' and mpls is 'yes'"
412
413 - name: Delete the ansible_tenant - cleanup before ending tests
414 cisco.aci.aci_tenant:
415 <<: *aci_info
416 tenant: ansible_tenant
417 state: absent