Debian Codegraph @

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

raw
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_uuid_pool:
14 <<: *api_info
15 name: "{{ item }}"
16 state: absent
17 loop:
18 - test_uuid_pool
19 - test_uuid_pool_2
20
21 - name: Create UUID pool - check-mode
22 cisco.intersight.intersight_uuid_pool:
23 <<: *api_info
24 name: test_uuid_pool
25 description: UUID Pool for lab use
26 prefix: "550E8400-E29B-41D4"
27 uuid_suffix_blocks:
28 - from: "A716-446655440000"
29 size: 100
30 - from: "A716-446655441000"
31 size: 200
32 tags:
33 - Key: Site
34 Value: RCDN
35 check_mode: true
36 register: creation_res_check_mode
37
38 - name: Verify UUID pool 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 UUID pool
45 cisco.intersight.intersight_uuid_pool:
46 <<: *api_info
47 name: test_uuid_pool
48 description: UUID Pool for lab use
49 prefix: "550E8400-E29B-41D4"
50 uuid_suffix_blocks:
51 - from: "A716-446655440000"
52 size: 100
53 - from: "A716-446655441000"
54 size: 200
55 tags:
56 - Key: Site
57 Value: RCDN
58 register: creation_res
59
60 - name: Fetch info for test_uuid_pool after creation
61 cisco.intersight.intersight_uuid_pool_info:
62 <<: *api_info
63 name: test_uuid_pool
64 register: creation_info_res
65
66 - name: Verify UUID pool creation by info
67 ansible.builtin.assert:
68 that:
69 - creation_res.changed
70 - creation_info_res.api_response[0].Name == 'test_uuid_pool'
71 - creation_info_res.api_response[0].UuidSuffixBlocks[0]["Size"] == 100
72 - creation_info_res.api_response[0].UuidSuffixBlocks[0]["From"] == 'A716-446655440000'
73 - creation_info_res.api_response[0].UuidSuffixBlocks[1]["Size"] == 200
74 - creation_info_res.api_response[0].UuidSuffixBlocks[1]["From"] == 'A716-446655441000'
75 - creation_info_res.api_response[0].Prefix == '550E8400-E29B-41D4'
76
77 - name: Verify UUID pool creation response aligns with info response
78 ansible.builtin.assert:
79 that:
80 - creation_res.api_response.Name == creation_info_res.api_response[0].Name
81 - creation_res.api_response.UuidSuffixBlocks[0]["Size"] == creation_info_res.api_response[0].UuidSuffixBlocks[0]["Size"]
82 - creation_res.api_response.UuidSuffixBlocks[0]["From"] == creation_info_res.api_response[0].UuidSuffixBlocks[0]["From"]
83 - creation_res.api_response.UuidSuffixBlocks[1]["Size"] == creation_info_res.api_response[0].UuidSuffixBlocks[1]["Size"]
84 - creation_res.api_response.UuidSuffixBlocks[1]["From"] == creation_info_res.api_response[0].UuidSuffixBlocks[1]["From"]
85 - creation_res.api_response.Prefix == creation_info_res.api_response[0].Prefix
86
87 - name: Create UUID pool (idempotency check)
88 cisco.intersight.intersight_uuid_pool:
89 <<: *api_info
90 name: test_uuid_pool
91 description: UUID Pool for lab use
92 prefix: "550E8400-E29B-41D4"
93 uuid_suffix_blocks:
94 - from: "A716-446655440000"
95 size: 100
96 - from: "A716-446655441000"
97 size: 200
98 tags:
99 - Key: Site
100 Value: RCDN
101 register: creation_res_ide
102
103 - name: Verify UUID pool creation (idempotency check)
104 ansible.builtin.assert:
105 that:
106 - not creation_res_ide.changed
107
108 - name: Validate failure due to missing uuid_suffix_blocks
109 cisco.intersight.intersight_uuid_pool:
110 <<: *api_info
111 name: test_uuid_pool_validate
112 description: "Test UUID pool description"
113 prefix: "550E8400-E29B-41D4"
114 tags: [
115 {
116 "Key": "Site", "Value": "Test"
117 },
118 {
119 "Key": "Site2", "Value": "Test3"
120 }
121 ]
122 state: present
123 register: failure_res
124 failed_when:
125 - "'state is present but all of the following are missing: uuid_suffix_blocks' not in failure_res.msg"
126
127 - name: Validate failure due to invalid UUID prefix format
128 cisco.intersight.intersight_uuid_pool:
129 <<: *api_info
130 name: test_uuid_pool_invalid_prefix
131 description: "Test UUID pool with invalid prefix"
132 prefix: "invalid-uuid-prefix"
133 uuid_suffix_blocks:
134 - from: "A716-446655440000"
135 size: 100
136 state: present
137 register: failure_res_prefix
138 failed_when:
139 - "'Invalid UUID prefix format' not in failure_res_prefix.msg"
140
141 - name: Validate failure due to invalid UUID suffix format
142 cisco.intersight.intersight_uuid_pool:
143 <<: *api_info
144 name: test_uuid_pool_invalid_suffix
145 description: "Test UUID pool with invalid suffix"
146 prefix: "550E8400-E29B-41D4"
147 uuid_suffix_blocks:
148 - from: "invalid-suffix"
149 size: 100
150 state: present
151 register: failure_res_suffix
152 failed_when:
153 - "'Invalid UUID suffix format' not in failure_res_suffix.msg"
154
155 - name: Create second UUID pool
156 cisco.intersight.intersight_uuid_pool:
157 <<: *api_info
158 name: test_uuid_pool_2
159 description: Second UUID Pool for testing
160 prefix: "12345678-1234-5678"
161 uuid_suffix_blocks:
162 - from: "9ABC-DEF123456789"
163 size: 50
164 - from: "FEDC-7654321098AB"
165 size: 25
166 tags:
167 - Key: Environment
168 Value: Test
169 register: creation_res_2
170
171 - name: Fetch info for test_uuid_pool_2 after creation
172 cisco.intersight.intersight_uuid_pool_info:
173 <<: *api_info
174 name: test_uuid_pool_2
175 register: creation_info_res_2
176
177 - name: Verify second UUID pool creation
178 ansible.builtin.assert:
179 that:
180 - creation_res_2.changed
181 - creation_info_res_2.api_response[0].Name == 'test_uuid_pool_2'
182 - creation_info_res_2.api_response[0].UuidSuffixBlocks[0]["Size"] == 50
183 - creation_info_res_2.api_response[0].UuidSuffixBlocks[0]["From"] == '9ABC-DEF123456789'
184 - creation_info_res_2.api_response[0].UuidSuffixBlocks[1]["Size"] == 25
185 - creation_info_res_2.api_response[0].UuidSuffixBlocks[1]["From"] == 'FEDC-7654321098AB'
186 - creation_info_res_2.api_response[0].Prefix == '12345678-1234-5678'
187
188 - name: Fetch all UUID pools under organization
189 cisco.intersight.intersight_uuid_pool_info:
190 <<: *api_info
191 register: creation_info_res_all
192
193 - name: Check that there are at least 2 UUID pools under this organization
194 ansible.builtin.assert:
195 that:
196 - creation_info_res_all.api_response | length >= 2
197
198 - name: Update UUID pool description
199 cisco.intersight.intersight_uuid_pool:
200 <<: *api_info
201 name: test_uuid_pool
202 description: Updated UUID Pool description
203 prefix: "550E8400-E29B-41D4"
204 uuid_suffix_blocks:
205 - from: "A716-446655440000"
206 size: 100
207 - from: "A716-446655441000"
208 size: 200
209 tags:
210 - Key: Site
211 Value: RCDN
212 register: update_res
213
214 - name: Fetch info for test_uuid_pool after update
215 cisco.intersight.intersight_uuid_pool_info:
216 <<: *api_info
217 name: test_uuid_pool
218 register: update_info_res
219
220 - name: Verify UUID pool update
221 ansible.builtin.assert:
222 that:
223 - update_res.changed
224 - update_info_res.api_response[0].Description == 'Updated UUID Pool description'
225
226 - name: Test UUID pool deletion - check-mode
227 cisco.intersight.intersight_uuid_pool:
228 <<: *api_info
229 name: test_uuid_pool
230 state: absent
231 check_mode: true
232 register: deletion_res_check_mode
233
234 - name: Verify UUID pool deletion - check-mode
235 ansible.builtin.assert:
236 that:
237 - deletion_res_check_mode is changed
238
239 - name: Delete UUID pool
240 cisco.intersight.intersight_uuid_pool:
241 <<: *api_info
242 name: test_uuid_pool
243 state: absent
244 register: deletion_res
245
246 - name: Verify UUID pool deletion
247 ansible.builtin.assert:
248 that:
249 - deletion_res.changed
250
251 - name: Delete UUID pool (idempotency check)
252 cisco.intersight.intersight_uuid_pool:
253 <<: *api_info
254 name: test_uuid_pool
255 state: absent
256 register: deletion_res_ide
257
258 - name: Verify UUID pool deletion (idempotency check)
259 ansible.builtin.assert:
260 that:
261 - not deletion_res_ide.changed
262
263 always:
264 - name: Remove test UUID pools
265 cisco.intersight.intersight_uuid_pool:
266 <<: *api_info
267 name: "{{ item }}"
268 state: absent
269 loop:
270 - test_uuid_pool
271 - test_uuid_pool_2