Debian Codegraph @

ansible_collections/cisco/intersight/tests/integration/targets/intersight_vsan_policy/tasks/tests.yml

raw symbols SCIP
1 ---
2 - block:
3 - name: Define anchor for Intersight API login info
4 ansible.builtin.set_fact:
5 api_info: &api_info
6 api_private_key: "{{ api_private_key }}"
7 api_key_id: "{{ api_key_id }}"
8 api_uri: "{{ api_uri | default(omit) }}"
9 validate_certs: "{{ validate_certs | default(omit) }}"
10 organization: "{{ organization }}"
11
12 - name: Make sure Env is clean
13 cisco.intersight.intersight_vsan_policy:
14 <<: *api_info
15 name: "{{ item }}"
16 state: absent
17 loop:
18 - test_vsan_policy
19 - test_vsan_policy_2
20 - test_vsan_policy_minimal
21 - test_vsan_policy_with_vsans
22 - test_vsan_policy_trunking
23
24 - name: Create vsan policy - check-mode
25 cisco.intersight.intersight_vsan_policy:
26 <<: *api_info
27 name: test_vsan_policy
28 description: "Test VSAN policy description"
29 enable_trunking: false
30 tags:
31 - Key: Site
32 Value: Test
33 - Key: Site2
34 Value: Test2
35 check_mode: true
36 register: creation_res_check_mode
37
38 - name: Verify vsan policy was not created - check-mode
39 ansible.builtin.assert:
40 that:
41 - creation_res_check_mode is changed
42 - creation_res_check_mode.api_response == {}
43
44 - name: Create vsan policy
45 cisco.intersight.intersight_vsan_policy:
46 <<: *api_info
47 name: test_vsan_policy
48 description: "Test VSAN policy description"
49 enable_trunking: false
50 tags:
51 - Key: Site
52 Value: Test
53 - Key: Site2
54 Value: Test2
55 register: creation_res
56
57 - name: Fetch info after creation
58 cisco.intersight.intersight_vsan_policy_info:
59 <<: *api_info
60 name: test_vsan_policy
61 register: creation_info_res
62
63 - name: Verify vsan policy creation by info
64 ansible.builtin.assert:
65 that:
66 - creation_res.changed
67 - creation_info_res.api_response.Name == 'test_vsan_policy'
68
69 - name: Create vsan policy (idempotency check)
70 cisco.intersight.intersight_vsan_policy:
71 <<: *api_info
72 name: test_vsan_policy
73 description: "Test VSAN policy description"
74 enable_trunking: false
75 tags:
76 - Key: Site
77 Value: Test
78 - Key: Site2
79 Value: Test2
80 register: creation_res_ide
81
82 - name: Fetch info after idempotency check
83 cisco.intersight.intersight_vsan_policy_info:
84 <<: *api_info
85 name: test_vsan_policy
86 register: idempotency_info_res
87
88 - name: Verify vsan policy creation (idempotency check)
89 ansible.builtin.assert:
90 that:
91 - not creation_res_ide.changed
92 - idempotency_info_res.api_response.Name == 'test_vsan_policy'
93 - idempotency_info_res.api_response.Description == 'Test VSAN policy description'
94
95 - name: Update description of an existing vsan policy
96 cisco.intersight.intersight_vsan_policy:
97 <<: *api_info
98 name: test_vsan_policy
99 description: "Updated VSAN policy description"
100 enable_trunking: false
101 tags:
102 - Key: Site
103 Value: Test
104 - Key: Site2
105 Value: Test2
106 register: changed_res
107
108 - name: Fetch info after change
109 cisco.intersight.intersight_vsan_policy_info:
110 <<: *api_info
111 name: test_vsan_policy
112 register: change_info_res
113
114 - name: Verify vsan policy change by info
115 ansible.builtin.assert:
116 that:
117 - changed_res.changed
118 - change_info_res.api_response.Name == 'test_vsan_policy'
119 - change_info_res.api_response.Description == 'Updated VSAN policy description'
120
121 - name: Create another vsan policy
122 cisco.intersight.intersight_vsan_policy:
123 <<: *api_info
124 name: test_vsan_policy_2
125 description: "Test another VSAN policy description"
126 enable_trunking: false
127 register: creation_res_b
128
129 - name: Fetch all vsan policies under selected organization
130 cisco.intersight.intersight_vsan_policy_info:
131 <<: *api_info
132 register: creation_info_res_b
133
134 - name: Check that there are at least 2 vsan policies under this organization
135 ansible.builtin.assert:
136 that:
137 - creation_info_res_b.api_response | length > 1
138
139 - name: Test creation without optional parameters
140 cisco.intersight.intersight_vsan_policy:
141 <<: *api_info
142 name: test_vsan_policy_minimal
143 register: creation_res_minimal
144
145 - name: Fetch info after minimal creation
146 cisco.intersight.intersight_vsan_policy_info:
147 <<: *api_info
148 name: test_vsan_policy_minimal
149 register: minimal_info_res
150
151 - name: Verify minimal vsan policy creation
152 ansible.builtin.assert:
153 that:
154 - creation_res_minimal.changed
155 - minimal_info_res.api_response.Name == 'test_vsan_policy_minimal'
156
157 - name: Create VSAN policy with multiple VSANs and different scopes
158 cisco.intersight.intersight_vsan_policy:
159 <<: *api_info
160 name: test_vsan_policy_with_vsans
161 description: "Policy with VSANs for different scopes"
162 enable_trunking: false
163 vsans:
164 - name: "vsan_uplink_100"
165 vsan_id: 100
166 fcoe_vlan_id: 100
167 vsan_scope: "uplink"
168 state: present
169 - name: "vsan_storage_200"
170 vsan_id: 200
171 fcoe_vlan_id: 200
172 vsan_scope: "storage"
173 state: present
174 - name: "vsan_common_300"
175 vsan_id: 300
176 fcoe_vlan_id: 300
177 vsan_scope: "common"
178 state: present
179 register: vsan_policy_with_vsans
180
181 - name: Fetch info after creating policy with VSANs
182 cisco.intersight.intersight_vsan_policy_info:
183 <<: *api_info
184 name: test_vsan_policy_with_vsans
185 register: vsans_creation_info_res
186
187 - name: Verify VSAN policy with VSANs creation
188 ansible.builtin.assert:
189 that:
190 - vsan_policy_with_vsans.changed
191 - vsans_creation_info_res.api_response.Name == 'test_vsan_policy_with_vsans'
192 - vsans_creation_info_res.api_response.vsans | length == 3
193 - vsans_creation_info_res.api_response.vsans[0].Name == 'vsan_uplink_100'
194 - vsans_creation_info_res.api_response.vsans[1].Name == 'vsan_storage_200'
195 - vsans_creation_info_res.api_response.vsans[2].Name == 'vsan_common_300'
196 - vsans_creation_info_res.api_response.vsans[0].VsanId == 100
197 - vsans_creation_info_res.api_response.vsans[1].VsanId == 200
198 - vsans_creation_info_res.api_response.vsans[2].VsanId == 300
199 - vsans_creation_info_res.api_response.vsans[0].FcoeVlan == 100
200 - vsans_creation_info_res.api_response.vsans[1].FcoeVlan == 200
201 - vsans_creation_info_res.api_response.vsans[2].FcoeVlan == 300
202 - vsans_creation_info_res.api_response.vsans[0].VsanScope == 'Uplink'
203 - vsans_creation_info_res.api_response.vsans[1].VsanScope == 'Storage'
204 - vsans_creation_info_res.api_response.vsans[2].VsanScope == 'Common'
205
206 - name: Create VSAN policy with trunking enabled
207 cisco.intersight.intersight_vsan_policy:
208 <<: *api_info
209 name: test_vsan_policy_trunking
210 description: "Policy with trunking enabled"
211 enable_trunking: true
212 vsans:
213 - name: "vsan_fabric_a"
214 vsan_id: 10
215 fcoe_vlan_id: 10
216 vsan_scope: "common"
217 - name: "vsan_fabric_b"
218 vsan_id: 20
219 fcoe_vlan_id: 20
220 vsan_scope: "common"
221 register: vsan_policy_trunking
222
223 - name: Fetch info after creating policy with trunking
224 cisco.intersight.intersight_vsan_policy_info:
225 <<: *api_info
226 name: test_vsan_policy_trunking
227 register: trunking_info_res
228
229 - name: Verify VSAN policy with trunking
230 ansible.builtin.assert:
231 that:
232 - vsan_policy_trunking.changed
233 - trunking_info_res.api_response.Name == 'test_vsan_policy_trunking'
234 - trunking_info_res.api_response.EnableTrunking == true
235 - trunking_info_res.api_response.vsans | length == 2
236 - trunking_info_res.api_response.vsans[0].Name == 'vsan_fabric_a'
237 - trunking_info_res.api_response.vsans[1].Name == 'vsan_fabric_b'
238
239 - name: Test info module - fetch specific policy with VSANs
240 cisco.intersight.intersight_vsan_policy_info:
241 <<: *api_info
242 name: test_vsan_policy_with_vsans
243 register: specific_policy_info
244
245 - name: Verify specific policy info
246 ansible.builtin.assert:
247 that:
248 - specific_policy_info.api_response.Name == 'test_vsan_policy_with_vsans'
249 - specific_policy_info.api_response.vsans | length == 3
250
251 - name: Test info module - fetch all policies
252 cisco.intersight.intersight_vsan_policy_info:
253 <<: *api_info
254 register: all_policies_info
255
256 - name: Verify all policies info
257 ansible.builtin.assert:
258 that:
259 - all_policies_info.api_response | length >= 4
260
261 - name: Test info module - filter by VSAN name
262 cisco.intersight.intersight_vsan_policy_info:
263 <<: *api_info
264 vsan_name: "vsan_uplink_100"
265 name: test_vsan_policy_with_vsans
266 register: vsan_filtered_info
267
268 - name: Verify VSAN filtered info
269 ansible.builtin.assert:
270 that:
271 - vsan_filtered_info.api_response.vsans | length == 1
272 - vsan_filtered_info.api_response.Name == 'test_vsan_policy_with_vsans'
273 - vsan_filtered_info.api_response.vsans[0].Name == 'vsan_uplink_100'
274 - vsan_filtered_info.api_response.vsans[0].VsanId == 100
275 - vsan_filtered_info.api_response.vsans[0].VsanScope == 'Uplink'
276
277 - name: Update VSAN policy - remove one VSAN
278 cisco.intersight.intersight_vsan_policy:
279 <<: *api_info
280 name: test_vsan_policy_with_vsans
281 description: "Policy with reduced VSANs"
282 enable_trunking: false
283 vsans:
284 - name: "vsan_uplink_100"
285 vsan_id: 100
286 fcoe_vlan_id: 100
287 vsan_scope: "uplink"
288 - name: "vsan_storage_200"
289 vsan_id: 200
290 fcoe_vlan_id: 200
291 vsan_scope: "storage"
292 state: absent
293 - name: "vsan_common_300"
294 vsan_id: 300
295 fcoe_vlan_id: 300
296 vsan_scope: "common"
297 register: vsan_removal_result
298
299 - name: Fetch info after VSAN removal
300 cisco.intersight.intersight_vsan_policy_info:
301 <<: *api_info
302 name: test_vsan_policy_with_vsans
303 register: vsan_removal_info_res
304
305 - name: Verify VSAN removal
306 ansible.builtin.assert:
307 that:
308 - vsan_removal_result.changed
309 - vsan_removal_info_res.api_response.Name == 'test_vsan_policy_with_vsans'
310 - vsan_removal_info_res.api_response.vsans | length == 2
311 - vsan_removal_info_res.api_response.vsans[0].Name == 'vsan_uplink_100'
312 - vsan_removal_info_res.api_response.vsans[1].Name == 'vsan_common_300'
313
314 always:
315 - name: Remove vsan policies
316 cisco.intersight.intersight_vsan_policy:
317 <<: *api_info
318 name: "{{ item }}"
319 state: absent
320 loop:
321 - test_vsan_policy
322 - test_vsan_policy_2
323 - test_vsan_policy_minimal
324 - test_vsan_policy_with_vsans
325 - test_vsan_policy_trunking