Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_vlan_pool/tasks/dynamic.yml

raw
1 # Test code for the ACI modules
2 # Copyright: (c) 2018, 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 # CLEAN ENVIRONMENT
7 - name: Remove dynamic vlan pool
8 cisco.aci.aci_vlan_pool: &dynamic_vlan_pool_absent
9 host: '{{ aci_hostname }}'
10 username: '{{ aci_username }}'
11 password: '{{ aci_password }}'
12 validate_certs: '{{ aci_validate_certs | default(false) }}'
13 use_ssl: '{{ aci_use_ssl | default(true) }}'
14 use_proxy: '{{ aci_use_proxy | default(true) }}'
15 output_level: '{{ aci_output_level | default("info") }}'
16 pool: anstest
17 pool_allocation_mode: dynamic
18 state: absent
19
20
21 # ADD VLAN POOL
22 - name: Add dynamic vlan pool (check_mode)
23 cisco.aci.aci_vlan_pool: &dynamic_vlan_pool_present
24 host: '{{ aci_hostname }}'
25 username: '{{ aci_username }}'
26 password: '{{ aci_password }}'
27 validate_certs: '{{ aci_validate_certs | default(false) }}'
28 use_ssl: '{{ aci_use_ssl | default(true) }}'
29 use_proxy: '{{ aci_use_proxy | default(true) }}'
30 output_level: '{{ aci_output_level | default("info") }}'
31 pool: anstest
32 pool_allocation_mode: dynamic
33 state: present
34 check_mode: true
35 register: cm_add_dynamic_vlan_pool
36
37 - name: Add dynamic vlan pool (normal mode)
38 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_present
39 register: nm_add_dynamic_vlan_pool
40
41 - name: Verify add_dynamic_vlan_pool
42 ansible.builtin.assert:
43 that:
44 - cm_add_dynamic_vlan_pool is changed
45 - nm_add_dynamic_vlan_pool is changed
46 - cm_add_dynamic_vlan_pool.sent.fvnsVlanInstP.attributes.allocMode == nm_add_dynamic_vlan_pool.sent.fvnsVlanInstP.attributes.allocMode == 'dynamic'
47 - cm_add_dynamic_vlan_pool.sent.fvnsVlanInstP.attributes.name == nm_add_dynamic_vlan_pool.sent.fvnsVlanInstP.attributes.name == 'anstest'
48 - cm_add_dynamic_vlan_pool.proposed.fvnsVlanInstP.attributes.allocMode == nm_add_dynamic_vlan_pool.proposed.fvnsVlanInstP.attributes.allocMode == 'dynamic'
49 - cm_add_dynamic_vlan_pool.proposed.fvnsVlanInstP.attributes.name == nm_add_dynamic_vlan_pool.proposed.fvnsVlanInstP.attributes.name == 'anstest'
50 - cm_add_dynamic_vlan_pool.previous == nm_add_dynamic_vlan_pool.previous == []
51 # NOTE: We cannot fix this easily
52 - cm_add_dynamic_vlan_pool.current == []
53 - nm_add_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.allocMode == 'dynamic'
54 - nm_add_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.descr == ''
55 - nm_add_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-dynamic'
56 - nm_add_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.name == 'anstest'
57 - nm_add_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.annotation == 'orchestrator:ansible'
58
59 - name: Add dynamic_vlan_pool again (check_mode)
60 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_present
61 check_mode: true
62 register: cm_add_dynamic_vlan_pool_again
63
64 - name: Add dynamic vlan pool again (normal mode)
65 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_present
66 register: nm_add_dynamic_vlan_pool_again
67
68 - name: Verify add_dynamic_vlan_pool_again
69 ansible.builtin.assert:
70 that:
71 - cm_add_dynamic_vlan_pool_again is not changed
72 - nm_add_dynamic_vlan_pool_again is not changed
73 - cm_add_dynamic_vlan_pool_again.current == nm_add_dynamic_vlan_pool_again.current == nm_add_dynamic_vlan_pool.current
74
75
76 # CHANGE VLAN POOL
77 - name: Change description of dynamic vlan pool (check_mode)
78 cisco.aci.aci_vlan_pool:
79 <<: *dynamic_vlan_pool_present
80 description: Ansible test dynamic vlan pool
81 check_mode: true
82 register: cm_add_dynamic_vlan_pool_descr
83
84 - name: Change description of dynamic vlan pool (normal mode)
85 cisco.aci.aci_vlan_pool:
86 <<: *dynamic_vlan_pool_present
87 description: Ansible test dynamic vlan pool
88 register: nm_add_dynamic_vlan_pool_descr
89
90 - name: Verify add_dynamic_vlan_pool_descr
91 ansible.builtin.assert:
92 that:
93 - cm_add_dynamic_vlan_pool_descr is changed
94 - nm_add_dynamic_vlan_pool_descr is changed
95 - cm_add_dynamic_vlan_pool_descr.sent.fvnsVlanInstP.attributes.descr == nm_add_dynamic_vlan_pool_descr.sent.fvnsVlanInstP.attributes.descr == 'Ansible test dynamic vlan pool'
96 - cm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.allocMode == nm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.allocMode == 'dynamic'
97 - cm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.descr == nm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.descr == 'Ansible test dynamic vlan pool'
98 - cm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.name == nm_add_dynamic_vlan_pool_descr.proposed.fvnsVlanInstP.attributes.name == 'anstest'
99 - cm_add_dynamic_vlan_pool_descr.previous == nm_add_dynamic_vlan_pool_descr.previous == cm_add_dynamic_vlan_pool_descr.current == nm_add_dynamic_vlan_pool.current
100 - nm_add_dynamic_vlan_pool_descr.current.0.fvnsVlanInstP.attributes.allocMode == 'dynamic'
101 - nm_add_dynamic_vlan_pool_descr.current.0.fvnsVlanInstP.attributes.descr == 'Ansible test dynamic vlan pool'
102 - nm_add_dynamic_vlan_pool_descr.current.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-dynamic'
103 - nm_add_dynamic_vlan_pool_descr.current.0.fvnsVlanInstP.attributes.name == 'anstest'
104
105 - name: Change description of dynamic vlan pool again (check_mode)
106 cisco.aci.aci_vlan_pool:
107 <<: *dynamic_vlan_pool_present
108 description: Ansible test dynamic vlan pool
109 check_mode: true
110 register: cm_add_dynamic_vlan_pool_descr_again
111
112 - name: Change description of dynamic vlan pool again (normal mode)
113 cisco.aci.aci_vlan_pool:
114 <<: *dynamic_vlan_pool_present
115 description: Ansible test dynamic vlan pool
116 register: nm_add_dynamic_vlan_pool_descr_again
117
118 - name: Verify add_dynamic_vlan_pool_descr_again
119 ansible.builtin.assert:
120 that:
121 - cm_add_dynamic_vlan_pool_descr_again is not changed
122 - nm_add_dynamic_vlan_pool_descr_again is not changed
123 - cm_add_dynamic_vlan_pool_descr_again.current == nm_add_dynamic_vlan_pool_descr_again.current == nm_add_dynamic_vlan_pool_descr.current
124
125
126 # ADD VLAN POOL AGAIN
127 - name: Add dynamic vlan pool again with no description (check_mode)
128 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_present
129 check_mode: true
130 register: cm_add_dynamic_vlan_pool_again_no_descr
131
132 - name: Add dynamic vlan pool again with no description (normal mode)
133 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_present
134 register: nm_add_dynamic_vlan_pool_again_no_descr
135
136 - name: Verify add_dynamic_vlan_pool_again_no_descr
137 ansible.builtin.assert:
138 that:
139 - cm_add_dynamic_vlan_pool_again_no_descr is not changed
140 - nm_add_dynamic_vlan_pool_again_no_descr is not changed
141 - cm_add_dynamic_vlan_pool_again_no_descr.current == nm_add_dynamic_vlan_pool_again_no_descr.current == nm_add_dynamic_vlan_pool_descr.current
142
143
144 # QUERY ALL VLAN POOLS
145 - name: Query all dynamic vlan pools (check_mode)
146 cisco.aci.aci_vlan_pool: &dynamic_vlan_pool_query
147 host: '{{ aci_hostname }}'
148 username: '{{ aci_username }}'
149 password: '{{ aci_password }}'
150 validate_certs: '{{ aci_validate_certs | default(false) }}'
151 use_ssl: '{{ aci_use_ssl | default(true) }}'
152 use_proxy: '{{ aci_use_proxy | default(true) }}'
153 output_level: '{{ aci_output_level | default("info") }}'
154 state: query
155 check_mode: true
156 register: cm_query_all_dynamic_vlan_pools
157
158 - name: Query all dynamic vlan pools (normal mode)
159 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_query
160 register: nm_query_all_dynamic_vlan_pools
161
162 - name: Verify query_all_dynamic_vlan_pools
163 ansible.builtin.assert:
164 that:
165 - cm_query_all_dynamic_vlan_pools is not changed
166 - nm_query_all_dynamic_vlan_pools is not changed
167 - cm_query_all_dynamic_vlan_pools == nm_query_all_dynamic_vlan_pools
168 - cm_query_all_dynamic_vlan_pools.current|length >= 1
169
170
171 # QUERY A VLAN POOL
172 - name: Query our dynamic vlan pool
173 cisco.aci.aci_vlan_pool:
174 <<: *dynamic_vlan_pool_query
175 pool: anstest
176 pool_allocation_mode: dynamic
177 check_mode: true
178 register: cm_query_dynamic_vlan_pool
179
180 - name: Query our dynamic vlan pool
181 cisco.aci.aci_vlan_pool:
182 <<: *dynamic_vlan_pool_query
183 pool: anstest
184 pool_allocation_mode: dynamic
185 register: nm_query_dynamic_vlan_pool
186
187 - name: Verify query_dynamic_vlan_pool
188 ansible.builtin.assert:
189 that:
190 - cm_query_dynamic_vlan_pool is not changed
191 - nm_query_dynamic_vlan_pool is not changed
192 - cm_query_dynamic_vlan_pool == nm_query_dynamic_vlan_pool
193 - nm_query_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.allocMode == 'dynamic'
194 - nm_query_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.descr == 'Ansible test dynamic vlan pool'
195 - nm_query_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-dynamic'
196 - nm_query_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.name == 'anstest'
197
198
199 # REMOVE VLAN POOL
200 - name: Remove dynamic vlan pool (check_mode)
201 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_absent
202 check_mode: true
203 register: cm_remove_dynamic_vlan_pool
204
205 - name: Remove dynamic vlan pool (normal mode)
206 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_absent
207 register: nm_remove_dynamic_vlan_pool
208
209 - name: Verify remove_dynamic_vlan_pool
210 ansible.builtin.assert:
211 that:
212 - cm_remove_dynamic_vlan_pool is changed
213 - nm_remove_dynamic_vlan_pool is changed
214 - cm_remove_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.allocMode == cm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.allocMode == nm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.allocMode == 'dynamic'
215 - cm_remove_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.descr == cm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.descr == nm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.descr == 'Ansible test dynamic vlan pool'
216 - cm_remove_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.dn == cm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.dn == nm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.dn == 'uni/infra/vlanns-[anstest]-dynamic'
217 - cm_remove_dynamic_vlan_pool.current.0.fvnsVlanInstP.attributes.name == cm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.name == nm_remove_dynamic_vlan_pool.previous.0.fvnsVlanInstP.attributes.name == 'anstest'
218 - nm_remove_dynamic_vlan_pool.current == []
219
220 - name: Remove dynamic vlan pool again (check_mode)
221 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_absent
222 check_mode: true
223 register: cm_remove_dynamic_vlan_pool_again
224
225 - name: Remove dynamic vlan pool again (normal mode)
226 cisco.aci.aci_vlan_pool: *dynamic_vlan_pool_absent
227 register: nm_remove_dynamic_vlan_pool_again
228
229 - name: Verify remove_dynamic_vlan_pool_again
230 ansible.builtin.assert:
231 that:
232 - cm_remove_dynamic_vlan_pool_again is not changed
233 - nm_remove_dynamic_vlan_pool_again is not changed
234 - cm_remove_dynamic_vlan_pool_again.proposed == nm_remove_dynamic_vlan_pool_again.proposed == {}
235 - cm_remove_dynamic_vlan_pool_again.sent == nm_remove_dynamic_vlan_pool_again.sent == {}
236 - cm_remove_dynamic_vlan_pool_again.previous == nm_remove_dynamic_vlan_pool_again.previous == []
237 - cm_remove_dynamic_vlan_pool_again.current == nm_remove_dynamic_vlan_pool_again.current == []
238
239
240 # QUERY NON-EXISTING VLAN POOL
241 - name: Query non-existing dynamic vlan pool (check_mode)
242 cisco.aci.aci_vlan_pool:
243 <<: *dynamic_vlan_pool_query
244 pool: anstest
245 pool_allocation_mode: dynamic
246 check_mode: true
247 register: cm_query_non_dynamic_vlan_pool
248
249 - name: Query non-existing dynamic vlan pool (normal mode)
250 cisco.aci.aci_vlan_pool:
251 <<: *dynamic_vlan_pool_query
252 pool: anstest
253 pool_allocation_mode: dynamic
254 register: nm_query_non_dynamic_vlan_pool
255
256 # TODO: Implement more tests
257 - name: Verify query_non_dynamic_vlan_pool
258 ansible.builtin.assert:
259 that:
260 - cm_query_non_dynamic_vlan_pool is not changed
261 - nm_query_non_dynamic_vlan_pool is not changed
262 - cm_remove_dynamic_vlan_pool_again.previous == nm_remove_dynamic_vlan_pool_again.previous == []
263 - cm_remove_dynamic_vlan_pool_again.current == nm_remove_dynamic_vlan_pool_again.current == []
264
265
266 # PROVOKE ERRORS
267 - name: Error when required parameter is missing
268 cisco.aci.aci_vlan_pool:
269 host: '{{ aci_hostname }}'
270 username: '{{ aci_username }}'
271 password: '{{ aci_password }}'
272 validate_certs: '{{ aci_validate_certs | default(false) }}'
273 use_ssl: '{{ aci_use_ssl | default(true) }}'
274 use_proxy: '{{ aci_use_proxy | default(true) }}'
275 output_level: '{{ aci_output_level | default("info") }}'
276 state: present
277 ignore_errors: true
278 register: error_on_missing_required_param
279
280 - name: Verify error_on_missing_required_param
281 ansible.builtin.assert:
282 that:
283 - error_on_missing_required_param is failed
284 - 'error_on_missing_required_param.msg == "state is present but all of the following are missing: pool, pool_allocation_mode"'
285
286 - name: Error when together parameter is missing
287 cisco.aci.aci_vlan_pool:
288 host: '{{ aci_hostname }}'
289 username: '{{ aci_username }}'
290 password: '{{ aci_password }}'
291 validate_certs: '{{ aci_validate_certs | default(false) }}'
292 use_ssl: '{{ aci_use_ssl | default(true) }}'
293 use_proxy: '{{ aci_use_proxy | default(true) }}'
294 output_level: '{{ aci_output_level | default("info") }}'
295 pool: anstest
296 state: present
297 ignore_errors: true
298 register: error_on_missing_together_param
299
300 - name: Verify error_on_missing_together_param
301 ansible.builtin.assert:
302 that:
303 - error_on_missing_together_param is failed
304 - 'error_on_missing_together_param.msg == "state is present but all of the following are missing: pool_allocation_mode"'