Debian Codegraph @

ansible_collections/cisco/mso/tests/integration/targets/ndo_node_setting/tasks/main.yml

raw
1 # Test code for the MSO modules
2 # Copyright: (c) 2024, Sabari Jaganathan (@sajagana) <[email protected]>
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 MultiSite host, username and password
7 ansible.builtin.fail:
8 msg: "Please define the following variables: mso_hostname, mso_username and mso_password."
9 when: mso_hostname is not defined or mso_username is not defined or mso_password is not defined
10
11 # CLEAN ENVIRONMENT
12 - name: Set vars
13 ansible.builtin.set_fact:
14 mso_info: &mso_info
15 host: "{{ mso_hostname }}"
16 username: "{{ mso_username }}"
17 password: "{{ mso_password }}"
18 validate_certs: "{{ mso_validate_certs | default(false) }}"
19 use_ssl: "{{ mso_use_ssl | default(true) }}"
20 use_proxy: "{{ mso_use_proxy | default(true) }}"
21 output_level: '{{ mso_output_level | default("debug") }}'
22
23 # QUERY VERSION
24 - name: Query MSO version
25 cisco.mso.mso_version:
26 <<: *mso_info
27 state: query
28 register: version
29
30 - name: Execute tasks only for NDO version > 4.3
31 when: version.current.version is version('4.3', '>')
32 block:
33 # Setup Part
34 - name: Ensure Fabric template not exist
35 cisco.mso.ndo_template: &ndo_fabric_template_absent
36 <<: *mso_info
37 template: '{{ ansible_fabric_template | default("ansible_test") }}'
38 template_type: fabric_policy
39 state: absent
40
41 # Fabric Template Setup
42 - name: Create a new Fabric template
43 cisco.mso.ndo_template:
44 <<: *ndo_fabric_template_absent
45 state: present
46
47 # Test Part
48 - name: Query all Node Settings when the Fabric template is empty
49 cisco.mso.ndo_node_setting:
50 <<: *mso_info
51 template: '{{ ansible_fabric_template | default("ansible_test") }}'
52 state: "query"
53 register: query_all_ns
54
55 - name: Assertion check for query all Node Settings when the Fabric template is empty
56 ansible.builtin.assert:
57 that:
58 - query_all_ns is not changed
59 - query_all_ns.current == {}
60
61 - name: Create Node Settings object with default values - check_mode
62 cisco.mso.ndo_node_setting: &cm_ns1_present
63 <<: *mso_info
64 template: '{{ ansible_fabric_template | default("ansible_test") }}'
65 name: "ns1"
66 state: "present"
67 output_level: debug
68 check_mode: true
69 register: cm_ns1_present
70
71 - name: Assertion check for create Node Settings object with default values - check_mode
72 ansible.builtin.assert:
73 that:
74 - cm_ns1_present is changed
75 - cm_ns1_present.current.name == "ns1"
76 - cm_ns1_present.previous == {}
77 - cm_ns1_present.proposed.name == "ns1"
78
79 - name: Create Node Settings object with default values - normal_mode
80 cisco.mso.ndo_node_setting:
81 <<: *cm_ns1_present
82 register: nm_ns1_present
83
84 - name: Create Node Settings object with default values - normal_mode again
85 cisco.mso.ndo_node_setting:
86 <<: *cm_ns1_present
87 register: nm_ns1_present_again
88
89 - name: Assertion check for create Node Settings object with default values - normal_mode
90 ansible.builtin.assert:
91 that:
92 - nm_ns1_present is changed
93 - nm_ns1_present.current.description == ""
94 - nm_ns1_present.current.name == "ns1"
95 - nm_ns1_present.current.uuid is defined
96 - nm_ns1_present.previous == {}
97 - nm_ns1_present_again is not changed
98
99 - name: Query ns1 Node Settings with name
100 cisco.mso.ndo_node_setting:
101 <<: *mso_info
102 template: '{{ ansible_fabric_template | default("ansible_test") }}'
103 name: "ns1"
104 state: "query"
105 register: query_ns1_with_name
106
107 - name: Assertion check for query ns1 Node Settings with name
108 ansible.builtin.assert:
109 that:
110 - query_ns1_with_name is not changed
111 - query_ns1_with_name.current.description == ""
112 - query_ns1_with_name.current.name == "ns1"
113 - query_ns1_with_name.current.uuid is defined
114
115 - name: Update ns1 object with synce and ptp values - check_mode
116 cisco.mso.ndo_node_setting: &cm_update_ns1
117 <<: *mso_info
118 template: '{{ ansible_fabric_template | default("ansible_test") }}'
119 name: "ns1"
120 description: "Updated description"
121 synce:
122 admin_state: "enabled"
123 quality_level: "option_2_generation_1"
124 ptp:
125 node_domain: 25
126 priority_2: 128
127 state: "present"
128 output_level: debug
129 check_mode: true
130 register: cm_update_ns1
131
132 - name: Assertion check for update ns1 object with synce and ptp values - check_mode
133 ansible.builtin.assert:
134 that:
135 - cm_update_ns1 is changed
136 - cm_update_ns1.current.description == "Updated description"
137 - cm_update_ns1.current.name == "ns1"
138 - cm_update_ns1.current.ptp.domain == 25
139 - cm_update_ns1.current.ptp.prio1 == 128
140 - cm_update_ns1.current.ptp.prio2 == 128
141 - cm_update_ns1.current.synce.adminState == "enabled"
142 - cm_update_ns1.current.synce.qlOption == "op2g1"
143 - cm_update_ns1.current.uuid is defined
144 - cm_update_ns1.previous.description == ""
145 - cm_update_ns1.previous.name == "ns1"
146 - cm_update_ns1.previous.uuid is defined
147 - cm_update_ns1.proposed.description == "Updated description"
148 - cm_update_ns1.proposed.name == "ns1"
149 - cm_update_ns1.proposed.ptp.domain == 25
150 - cm_update_ns1.proposed.ptp.prio1 == 128
151 - cm_update_ns1.proposed.ptp.prio2 == 128
152 - cm_update_ns1.proposed.synce.adminState == "enabled"
153 - cm_update_ns1.proposed.synce.qlOption == "op2g1"
154 - cm_update_ns1.proposed.uuid is defined
155
156 - name: Update ns1 object with synce and ptp values - normal_mode
157 cisco.mso.ndo_node_setting:
158 <<: *cm_update_ns1
159 register: nm_update_ns1
160
161 - name: Update ns1 object with synce and ptp values - normal_mode again
162 cisco.mso.ndo_node_setting:
163 <<: *cm_update_ns1
164 register: nm_update_ns1_again
165
166 - name: Assertion check for update ns1 object with synce and ptp values - normal_mode
167 ansible.builtin.assert:
168 that:
169 - nm_update_ns1 is changed
170 - nm_update_ns1.current.description == "Updated description"
171 - nm_update_ns1.current.name == "ns1"
172 - nm_update_ns1.current.ptp.domain == 25
173 - nm_update_ns1.current.ptp.prio1 == 128
174 - nm_update_ns1.current.ptp.prio2 == 128
175 - nm_update_ns1.current.synce.adminState == "enabled"
176 - nm_update_ns1.current.synce.qlOption == "op2g1"
177 - nm_update_ns1.current.uuid is defined
178 - nm_update_ns1.previous.description == ""
179 - nm_update_ns1.previous.name == "ns1"
180 - nm_update_ns1_again is not changed
181
182 - name: Clear ns1 synce values with UUID
183 cisco.mso.ndo_node_setting:
184 <<: *mso_info
185 template: '{{ ansible_fabric_template | default("ansible_test") }}'
186 uuid: "{{ nm_update_ns1.current.uuid }}"
187 synce:
188 state: "disabled"
189 state: "present"
190 register: clear_ns1_synce
191
192 - name: Assertion check for clear ns1 synce values with UUID
193 ansible.builtin.assert:
194 that:
195 - clear_ns1_synce is changed
196 - clear_ns1_synce.current.description == "Updated description"
197 - clear_ns1_synce.current.name == "ns1"
198 - clear_ns1_synce.current.ptp.domain == 25
199 - clear_ns1_synce.current.ptp.prio1 == 128
200 - clear_ns1_synce.current.ptp.prio2 == 128
201 - clear_ns1_synce.current.uuid is defined
202 - clear_ns1_synce.previous.description == "Updated description"
203 - clear_ns1_synce.previous.name == "ns1"
204 - clear_ns1_synce.previous.ptp.domain == 25
205 - clear_ns1_synce.previous.ptp.prio1 == 128
206 - clear_ns1_synce.previous.ptp.prio2 == 128
207 - clear_ns1_synce.previous.synce.adminState == "enabled"
208 - clear_ns1_synce.previous.synce.qlOption == "op2g1"
209
210 - name: Enable ns1 synce values with UUID
211 cisco.mso.ndo_node_setting:
212 <<: *mso_info
213 template: '{{ ansible_fabric_template | default("ansible_test") }}'
214 uuid: "{{ nm_update_ns1.current.uuid }}"
215 synce:
216 state: "enabled"
217 state: "present"
218 register: nt_ns1_synce
219 ignore_errors: true
220
221 - name: Assertion check for enable ns1 synce values with UUID
222 ansible.builtin.assert:
223 that:
224 - nt_ns1_synce is not changed
225 - 'nt_ns1_synce.msg == "state is enabled but all of the following are missing: admin_state, quality_level found in synce"'
226
227 - name: Clear ns1 ptp values
228 cisco.mso.ndo_node_setting:
229 <<: *mso_info
230 template: '{{ ansible_fabric_template | default("ansible_test") }}'
231 uuid: "{{ nm_update_ns1.current.uuid }}"
232 ptp:
233 state: "disabled"
234 state: "present"
235 register: clear_ns1_ptp
236
237 - name: Assertion check for clear ns1 ptp values
238 ansible.builtin.assert:
239 that:
240 - clear_ns1_ptp is changed
241 - clear_ns1_ptp.current.description == "Updated description"
242 - clear_ns1_ptp.current.name == "ns1"
243 - clear_ns1_ptp.current.uuid is defined
244 - clear_ns1_ptp.previous.description == "Updated description"
245 - clear_ns1_ptp.previous.name == "ns1"
246 - clear_ns1_ptp.previous.ptp.domain == 25
247 - clear_ns1_ptp.previous.ptp.prio1 == 128
248 - clear_ns1_ptp.previous.ptp.prio2 == 128
249 - clear_ns1_ptp.previous.uuid is defined
250
251 - name: Enable ns1 ptp values
252 cisco.mso.ndo_node_setting:
253 <<: *mso_info
254 template: '{{ ansible_fabric_template | default("ansible_test") }}'
255 uuid: "{{ nm_update_ns1.current.uuid }}"
256 ptp:
257 state: "enabled"
258 state: "present"
259 register: nt_ns1_ptp
260 ignore_errors: true
261
262 - name: Assertion check for enable ns1 ptp values
263 ansible.builtin.assert:
264 that:
265 - nt_ns1_ptp is not changed
266 - 'nt_ns1_ptp.msg == "state is enabled but all of the following are missing: node_domain, priority_2 found in ptp"'
267
268 - name: Query ns1 Node Settings with UUID
269 cisco.mso.ndo_node_setting:
270 <<: *mso_info
271 template: '{{ ansible_fabric_template | default("ansible_test") }}'
272 uuid: "{{ nm_update_ns1.current.uuid }}"
273 state: "query"
274 register: query_ns1_with_uuid
275
276 - name: Assertion check for query ns1 Node Settings with UUID
277 ansible.builtin.assert:
278 that:
279 - query_ns1_with_uuid is not changed
280 - query_ns1_with_uuid.current.description == "Updated description"
281 - query_ns1_with_uuid.current.name == "ns1"
282 - query_ns1_with_uuid.current.uuid is defined
283
284 - name: Add ns1 synce values and name
285 cisco.mso.ndo_node_setting:
286 <<: *mso_info
287 template: '{{ ansible_fabric_template | default("ansible_test") }}'
288 uuid: "{{ nm_update_ns1.current.uuid }}"
289 name: "ns1_new"
290 description: ""
291 synce:
292 admin_state: "disabled"
293 quality_level: "option_1"
294 state: "present"
295 register: add_ns1_synce
296
297 - name: Update ns1_new synce quality_level value
298 cisco.mso.ndo_node_setting:
299 <<: *mso_info
300 template: '{{ ansible_fabric_template | default("ansible_test") }}'
301 uuid: "{{ nm_update_ns1.current.uuid }}"
302 name: "ns1_new"
303 description: ""
304 synce:
305 admin_state: "disabled"
306 quality_level: "option_2_generation_2"
307 state: "present"
308 register: ns1_synce_quality_level_change
309
310 - name: Assertion check for add ns1 synce values and name
311 ansible.builtin.assert:
312 that:
313 - add_ns1_synce is changed
314 - add_ns1_synce.current.description == ""
315 - add_ns1_synce.current.name == "ns1_new"
316 - add_ns1_synce.current.synce.adminState == "disabled"
317 - add_ns1_synce.current.synce.qlOption == "op1"
318 - add_ns1_synce.current.uuid is defined
319 - add_ns1_synce.previous.description == "Updated description"
320 - add_ns1_synce.previous.name == "ns1"
321 - add_ns1_synce.previous.uuid is defined
322 - ns1_synce_quality_level_change is changed
323 - ns1_synce_quality_level_change.current.synce.qlOption == "op2g2"
324 - ns1_synce_quality_level_change.previous.synce.qlOption == "op1"
325
326 - name: Add ns1 ptp values
327 cisco.mso.ndo_node_setting:
328 <<: *mso_info
329 template: '{{ ansible_fabric_template | default("ansible_test") }}'
330 uuid: "{{ nm_update_ns1.current.uuid }}"
331 ptp:
332 node_domain: 26
333 priority_2: 128
334 state: "present"
335 register: add_ns1_ptp
336
337 - name: Assertion check for add ns1 ptp values
338 ansible.builtin.assert:
339 that:
340 - add_ns1_ptp is changed
341 - add_ns1_ptp.current.description == ""
342 - add_ns1_ptp.current.name == "ns1_new"
343 - add_ns1_ptp.current.ptp.domain == 26
344 - add_ns1_ptp.current.ptp.prio1 == 128
345 - add_ns1_ptp.current.ptp.prio2 == 128
346 - add_ns1_ptp.current.synce.adminState == "disabled"
347 - add_ns1_ptp.current.synce.qlOption == "op2g2"
348 - add_ns1_ptp.current.uuid is defined
349 - add_ns1_ptp.previous.description == ""
350 - add_ns1_ptp.previous.name == "ns1_new"
351 - add_ns1_ptp.previous.synce.adminState == "disabled"
352 - add_ns1_ptp.previous.synce.qlOption == "op2g2"
353 - add_ns1_ptp.previous.uuid is defined
354
355 - name: Add ns2 with synce and ptp values
356 cisco.mso.ndo_node_setting:
357 <<: *cm_update_ns1
358 name: ns2
359 state: "present"
360 register: add_ns2
361
362 - name: Assertion check for add ns2 with synce and ptp values
363 ansible.builtin.assert:
364 that:
365 - add_ns2 is changed
366 - add_ns2.current.description == "Updated description"
367 - add_ns2.current.name == "ns2"
368 - add_ns2.current.ptp.domain == 25
369 - add_ns2.current.ptp.prio1 == 128
370 - add_ns2.current.ptp.prio2 == 128
371 - add_ns2.current.synce.adminState == "enabled"
372 - add_ns2.current.synce.qlOption == "op2g1"
373 - add_ns2.current.uuid is defined
374 - add_ns2.previous == {}
375
376 - name: Query all Node Settings
377 cisco.mso.ndo_node_setting:
378 <<: *mso_info
379 template: '{{ ansible_fabric_template | default("ansible_test") }}'
380 state: "query"
381 register: query_all_ns_again
382
383 - name: Assertion check for query all Node Settings
384 ansible.builtin.assert:
385 that:
386 - query_all_ns_again is not changed
387 - query_all_ns_again.current | length == 2
388 - "'ns1_new' in query_all_ns_again.current | map(attribute='name') | list"
389 - "'ns2' in query_all_ns_again.current | map(attribute='name') | list"
390
391 - name: Remove ns2 Node Settings with UUID
392 cisco.mso.ndo_node_setting:
393 <<: *mso_info
394 template: '{{ ansible_fabric_template | default("ansible_test") }}'
395 uuid: "{{ add_ns2.current.uuid }}"
396 state: "absent"
397 register: rm_ns2_uuid
398
399 - name: Assertion check for remove ns4 Node Settings with UUID
400 ansible.builtin.assert:
401 that:
402 - rm_ns2_uuid is changed
403 - rm_ns2_uuid.current == {}
404 - rm_ns2_uuid.previous.description == "Updated description"
405 - rm_ns2_uuid.previous.name == "ns2"
406 - rm_ns2_uuid.previous.uuid is defined
407
408 - name: Remove ns1_new Node Settings with check_mode
409 cisco.mso.ndo_node_setting:
410 <<: *mso_info
411 template: '{{ ansible_fabric_template | default("ansible_test") }}'
412 name: "ns1_new"
413 state: "absent"
414 output_level: debug
415 check_mode: true
416 register: cm_rm_ns1
417
418 - name: Assertion check for remove ns1_new Node Settings with check_mode
419 ansible.builtin.assert:
420 that:
421 - cm_rm_ns1 is changed
422 - cm_rm_ns1.current == {}
423 - cm_rm_ns1.previous != {}
424
425 - name: Remove ns1_new Node Settings with normal_mode
426 cisco.mso.ndo_node_setting:
427 <<: *mso_info
428 template: '{{ ansible_fabric_template | default("ansible_test") }}'
429 name: "ns1_new"
430 state: "absent"
431 output_level: debug
432 register: nm_rm_ns1
433
434 - name: Assertion check for remove ns1_new Node Settings with normal_mode
435 ansible.builtin.assert:
436 that:
437 - nm_rm_ns1 is changed
438 - nm_rm_ns1.current == {}
439 - nm_rm_ns1.previous != {}
440
441 - name: Remove ns1_new Node Settings with normal_mode again
442 cisco.mso.ndo_node_setting:
443 <<: *mso_info
444 template: '{{ ansible_fabric_template | default("ansible_test") }}'
445 name: "ns1_new"
446 state: "absent"
447 register: nm_rm_ns1_again
448
449 - name: Assertion check for remove ns1_new Node Settings with normal_mode again
450 ansible.builtin.assert:
451 that:
452 - nm_rm_ns1_again is not changed
453 - nm_rm_ns1_again.current == {}
454 - nm_rm_ns1_again.previous == {}
455
456 # Cleanup Part
457 - name: Remove Fabric template
458 cisco.mso.ndo_template:
459 <<: *ndo_fabric_template_absent