Debian Codegraph @

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

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2020, Cindy Zhao (@cizhao)
3
4 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 - name: Test that we have an ACI APIC host, ACI username and ACI password
7 ansible.builtin.fail:
8 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
9 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
10
11 - name: Set vars
12 ansible.builtin.set_fact:
13 aci_info: &aci_info
14 host: "{{ aci_hostname }}"
15 username: "{{ aci_username }}"
16 password: "{{ aci_password }}"
17 validate_certs: '{{ aci_validate_certs | default(false) }}'
18 use_ssl: '{{ aci_use_ssl | default(true) }}'
19 use_proxy: '{{ aci_use_proxy | default(true) }}'
20 output_level: debug
21
22 # CLEAN ENVIRONMENT
23 - name: Remove the ansible_tenant
24 cisco.aci.aci_tenant:
25 <<: *aci_info
26 tenant: ansible_tenant
27 state: absent
28
29 - name: Verify Cloud and Non-Cloud Sites in use.
30 ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
31
32 - name: Execute tasks only for non-cloud sites
33 when: query_cloud.current == [] # This condition will execute only non-cloud sites
34 block: # block specifies execution of tasks within, based on conditions
35 - name: Add a new tenant
36 cisco.aci.aci_tenant:
37 <<: *aci_info
38 tenant: ansible_tenant
39 description: Ansible tenant
40 state: present
41
42 - name: Add a new l3out
43 cisco.aci.aci_l3out:
44 <<: *aci_info
45 tenant: ansible_tenant
46 name: ansible_l3out
47 description: l3out for Ansible tenant
48 domain: ansible_dom
49 route_control: export
50 vrf: ansible_vrf
51 l3protocol: ospf
52 state: present
53
54 - name: Add a new ExtEpg
55 cisco.aci.aci_l3out_extepg:
56 <<: *aci_info
57 tenant: ansible_tenant
58 l3out: ansible_l3out
59 name: ansible_extEpg
60 description: ExtEpg for Ansible l3out
61 state: present
62
63 - name: Add a subnet (check mode)
64 cisco.aci.aci_l3out_extsubnet:
65 <<: *aci_info
66 tenant: ansible_tenant
67 l3out: ansible_l3out
68 extepg: ansible_extEpg
69 subnet_name: test
70 network: 192.0.2.0/24
71 state: present
72 check_mode: true
73 register: cm_add_subnet
74
75 - name: Add a subnet (normal mode)
76 cisco.aci.aci_l3out_extsubnet:
77 <<: *aci_info
78 tenant: ansible_tenant
79 l3out: ansible_l3out
80 extepg: ansible_extEpg
81 subnet_name: test
82 network: 192.0.2.0/24
83 state: present
84 register: nm_add_subnet
85
86 - name: Verify cm_add_subnet and nm_add_subnet
87 ansible.builtin.assert:
88 that:
89 - cm_add_subnet is changed
90 - nm_add_subnet is changed
91 - cm_add_subnet.proposed.l3extSubnet.attributes.ip == "192.0.2.0/24"
92 - cm_add_subnet.proposed.l3extSubnet.attributes.name == "test"
93 - nm_add_subnet.current.0.l3extSubnet.attributes.ip == "192.0.2.0/24"
94 - nm_add_subnet.current.0.l3extSubnet.attributes.name == "test"
95 - nm_add_subnet.current.0.l3extSubnet.attributes.scope == "import-security"
96 - nm_add_subnet.current.0.l3extSubnet.attributes.annotation == 'orchestrator:ansible'
97
98 - name: Add subnet again
99 cisco.aci.aci_l3out_extsubnet:
100 <<: *aci_info
101 tenant: ansible_tenant
102 l3out: ansible_l3out
103 extepg: ansible_extEpg
104 subnet_name: test
105 network: 192.0.2.0/24
106 state: present
107 register: nm_add_subnet_again
108
109 - name: Verify nm_add_subnet_again
110 ansible.builtin.assert:
111 that:
112 - nm_add_subnet_again is not changed
113
114 - name: Change subnet (check_mode)
115 cisco.aci.aci_l3out_extsubnet:
116 <<: *aci_info
117 tenant: ansible_tenant
118 l3out: ansible_l3out
119 extepg: ansible_extEpg
120 network: 192.0.2.0/24
121 subnet_name: ansible_test
122 description: description for subnet
123 scope: [ shared-security, import-security ]
124 state: present
125 check_mode: true
126 register: cm_change_subnet
127
128 - name: Change subnet (normal mode)
129 cisco.aci.aci_l3out_extsubnet:
130 <<: *aci_info
131 tenant: ansible_tenant
132 l3out: ansible_l3out
133 extepg: ansible_extEpg
134 network: 192.0.2.0/24
135 subnet_name: ansible_test
136 description: description for subnet
137 scope: [ shared-security, import-security ]
138 state: present
139 register: nm_change_subnet
140
141 - name: Verify cm_change_subnet and nm_change_subnet
142 ansible.builtin.assert:
143 that:
144 - cm_change_subnet is changed
145 - nm_change_subnet is changed
146 - cm_change_subnet.previous.0.l3extSubnet.attributes.descr == nm_change_subnet.previous.0.l3extSubnet.attributes.descr == ""
147 - cm_change_subnet.previous.0.l3extSubnet.attributes.name == nm_change_subnet.previous.0.l3extSubnet.attributes.name == "test"
148 - cm_change_subnet.previous.0.l3extSubnet.attributes.scope == nm_change_subnet.previous.0.l3extSubnet.attributes.scope == "import-security"
149 - cm_change_subnet.proposed.l3extSubnet.attributes.descr == "description for subnet"
150 - cm_change_subnet.proposed.l3extSubnet.attributes.name == "ansible_test"
151 - cm_change_subnet.proposed.l3extSubnet.attributes.scope == "import-security,shared-security"
152 - nm_change_subnet.current.0.l3extSubnet.attributes.descr == "description for subnet"
153 - nm_change_subnet.current.0.l3extSubnet.attributes.name == "ansible_test"
154 - nm_change_subnet.current.0.l3extSubnet.attributes.scope == "import-security,shared-security"
155
156 - name: Add another subnet (normal mode)
157 cisco.aci.aci_l3out_extsubnet:
158 <<: *aci_info
159 tenant: ansible_tenant
160 l3out: ansible_l3out
161 extepg: ansible_extEpg
162 network: 192.1.2.0/24
163 state: present
164 register: nm_add_another_subnet
165
166 - name: Verify nm_add_another_subnet
167 ansible.builtin.assert:
168 that:
169 - nm_add_another_subnet is changed
170 - nm_add_another_subnet.current.0.l3extSubnet.attributes.ip == "192.1.2.0/24"
171
172 - name: Query all subnets
173 cisco.aci.aci_l3out_extsubnet:
174 <<: *aci_info
175 tenant: ansible_tenant
176 l3out: ansible_l3out
177 extepg: ansible_extEpg
178 state: query
179 register: query_all
180
181 - name: Query specific subnet
182 cisco.aci.aci_l3out_extsubnet:
183 <<: *aci_info
184 tenant: ansible_tenant
185 l3out: ansible_l3out
186 extepg: ansible_extEpg
187 network: 192.0.2.0/24
188 state: query
189 register: query_subnet
190
191 - name: Verify query_all and query_subnet
192 ansible.builtin.assert:
193 that:
194 - query_all is not changed
195 - query_subnet is not changed
196 - query_all.current.0.l3extInstP.children | length == 2
197 - query_subnet.current.0.l3extSubnet.attributes.name == "ansible_test"
198 - query_subnet.current.0.l3extSubnet.attributes.ip == "192.0.2.0/24"
199
200 - name: Remove subnet
201 cisco.aci.aci_l3out_extsubnet:
202 <<: *aci_info
203 tenant: ansible_tenant
204 l3out: ansible_l3out
205 extepg: ansible_extEpg
206 network: 192.0.2.0/24
207 state: absent
208 register: rm_subnet
209
210 - name: Verify rm_subnet
211 ansible.builtin.assert:
212 that:
213 - rm_subnet is changed
214 - rm_subnet.current == []
215 - rm_subnet.previous.0.l3extSubnet.attributes.ip == "192.0.2.0/24"
216 - rm_subnet.previous.0.l3extSubnet.attributes.name == "ansible_test"
217
218 - name: Change subnet aggregate mismatch without scope (normal mode)
219 cisco.aci.aci_l3out_extsubnet:
220 <<: *aci_info
221 tenant: ansible_tenant
222 l3out: ansible_l3out
223 extepg: ansible_extEpg
224 network: 0.0.0.0/0
225 subnet_name: ansible_test
226 description: description for subnet
227 aggregate: [ export-rtctrl, import-rtctrl ]
228 state: present
229 register: nm_aggregate_scope_none
230 ignore_errors: true
231
232 - name: asserts failed aggregate creation tasks
233 ansible.builtin.assert:
234 that:
235 - nm_aggregate_scope_none is failed
236 - nm_aggregate_scope_none.msg.startswith("missing parameter(s) required by 'aggregate'")
237
238 - name: Change subnet aggregate mismatch (normal mode)
239 cisco.aci.aci_l3out_extsubnet:
240 <<: *aci_info
241 tenant: ansible_tenant
242 l3out: ansible_l3out
243 extepg: ansible_extEpg
244 network: 0.0.0.0/0
245 subnet_name: ansible_test
246 description: description for subnet
247 scope: [ import-security ]
248 aggregate: [ export-rtctrl, import-rtctrl ]
249 state: present
250 register: nm_aggregate_scope_mismatch
251 ignore_errors: true
252
253 - name: asserts failed aggregate creation tasks
254 ansible.builtin.assert:
255 that:
256 - nm_aggregate_scope_mismatch is failed
257 - nm_aggregate_scope_mismatch.msg == "All aggregate values ['export-rtctrl', 'import-rtctrl'] need to be defined in scope ['import-security']."
258
259 - name: Change subnet aggregate match (check mode)
260 cisco.aci.aci_l3out_extsubnet:
261 <<: *aci_info
262 tenant: ansible_tenant
263 l3out: ansible_l3out
264 extepg: ansible_extEpg
265 network: 0.0.0.0/0
266 subnet_name: ansible_test
267 description: description for subnet
268 scope: [ export-rtctrl, import-rtctrl, import-security ]
269 aggregate: [ export-rtctrl, import-rtctrl ]
270 state: present
271 check_mode: true
272 register: cm_aggregate_scope_match
273
274 - name: Change subnet aggregate match (normal mode)
275 cisco.aci.aci_l3out_extsubnet:
276 <<: *aci_info
277 tenant: ansible_tenant
278 l3out: ansible_l3out
279 extepg: ansible_extEpg
280 network: 0.0.0.0/0
281 subnet_name: ansible_test
282 description: description for subnet
283 scope: [ export-rtctrl, import-rtctrl, import-security ]
284 aggregate: [ export-rtctrl, import-rtctrl ]
285 state: present
286 register: nm_aggregate_scope_match
287
288 - name: asserts success aggregate creation task
289 ansible.builtin.assert:
290 that:
291 - cm_aggregate_scope_match is changed
292 - cm_aggregate_scope_match.proposed.l3extSubnet.attributes.ip == "0.0.0.0/0"
293 - cm_aggregate_scope_match.proposed.l3extSubnet.attributes.name == "ansible_test"
294 - cm_aggregate_scope_match.proposed.l3extSubnet.attributes.scope == "export-rtctrl,import-rtctrl,import-security"
295 - cm_aggregate_scope_match.proposed.l3extSubnet.attributes.aggregate == "export-rtctrl,import-rtctrl"
296 - nm_aggregate_scope_match.current.0.l3extSubnet.attributes.ip == "0.0.0.0/0"
297 - nm_aggregate_scope_match.current.0.l3extSubnet.attributes.name == "ansible_test"
298 - nm_aggregate_scope_match.current.0.l3extSubnet.attributes.scope == "export-rtctrl,import-rtctrl,import-security"
299 - nm_aggregate_scope_match.current.0.l3extSubnet.attributes.aggregate == "export-rtctrl,import-rtctrl"
300
301 - name: Change subnet other aggregate order (normal mode)
302 cisco.aci.aci_l3out_extsubnet:
303 <<: *aci_info
304 tenant: ansible_tenant
305 l3out: ansible_l3out
306 extepg: ansible_extEpg
307 network: 0.0.0.0/0
308 subnet_name: ansible_test
309 description: description for subnet
310 scope: [ export-rtctrl, import-rtctrl, import-security ]
311 aggregate: [ import-rtctrl, export-rtctrl ]
312 state: present
313 register: nm_aggregate_scope_match
314
315 - name: asserts success aggregate creation task reversed input order
316 ansible.builtin.assert:
317 that:
318 - nm_aggregate_scope_match is not changed