Debian Codegraph @

ansible_collections/cloudscale_ch/cloud/tests/integration/targets/volume/tasks/tests.yml

raw
1 ---
2 - name: Create volume in check mode
3 cloudscale_ch.cloud.volume:
4 name: '{{ cloudscale_resource_prefix }}-vol'
5 zone: '{{ cloudscale_test_zone }}'
6 size_gb: 50
7 tags:
8 project: ansible-test
9 stage: production
10 sla: 24-7
11 check_mode: yes
12 register: vol
13 - name: 'VERIFY: Create volume in check mode'
14 assert:
15 that:
16 - vol is successful
17 - vol is changed
18 - vol.state == 'absent'
19
20 - name: Create volume
21 cloudscale_ch.cloud.volume:
22 name: '{{ cloudscale_resource_prefix }}-vol'
23 zone: '{{ cloudscale_test_zone }}'
24 size_gb: 50
25 tags:
26 project: ansible-test
27 stage: production
28 sla: 24-7
29 register: vol
30 - name: 'VERIFY: Create volume'
31 assert:
32 that:
33 - vol is successful
34 - vol is changed
35 - vol.size_gb == 50
36 - vol.name == cloudscale_resource_prefix + '-vol'
37 - vol.zone.slug == cloudscale_test_zone
38 - vol.tags.project == 'ansible-test'
39 - vol.tags.stage == 'production'
40 - vol.tags.sla == '24-7'
41
42 - name: Create volume idempotence
43 cloudscale_ch.cloud.volume:
44 name: '{{ cloudscale_resource_prefix }}-vol'
45 zone: '{{ cloudscale_test_zone }}'
46 size_gb: 50
47 tags:
48 project: ansible-test
49 stage: production
50 sla: 24-7
51 register: vol
52 - name: 'VERIFY: Create volume idempotence'
53 assert:
54 that:
55 - vol is successful
56 - vol is not changed
57 - vol.size_gb == 50
58 - vol.name == cloudscale_resource_prefix + '-vol'
59 - vol.zone.slug == cloudscale_test_zone
60 - vol.tags.project == 'ansible-test'
61 - vol.tags.stage == 'production'
62 - vol.tags.sla == '24-7'
63
64 - name: Create volume snapshot
65 cloudscale_ch.cloud.volume_snapshot:
66 name: '{{ cloudscale_resource_prefix }}-vol-snap'
67 source_volume: '{{ vol.uuid }}'
68 register: vol_snap_first
69
70 - name: Revert volume to snapshot
71 cloudscale_ch.cloud.volume:
72 uuid: '{{ vol.uuid }}'
73 revert: '{{ vol_snap_first.uuid }}'
74 register: revert
75 - name: 'VERIFY: Revert volume to snapshot'
76 assert:
77 that:
78 - revert is successful
79 - revert is changed
80 - vol_snap_first.uuid == revert.revert
81
82 - name: Attach existing volume by name to server in check mode
83 cloudscale_ch.cloud.volume:
84 name: '{{ cloudscale_resource_prefix }}-vol'
85 servers:
86 - '{{ server.uuid }}'
87 check_mode: yes
88 register: vol
89 - name: 'VERIFY: Attach existing volume by name to server in check mode'
90 assert:
91 that:
92 - vol is successful
93 - vol is changed
94 - server.uuid not in vol.servers
95
96 - name: Attach existing volume by name to server
97 cloudscale_ch.cloud.volume:
98 name: '{{ cloudscale_resource_prefix }}-vol'
99 servers:
100 - '{{ server.uuid }}'
101 register: vol
102 - name: 'VERIFY: Attach existing volume by name to server'
103 assert:
104 that:
105 - vol is successful
106 - vol is changed
107 - server.uuid in vol.servers | map(attribute="uuid")
108
109 - name: Attach existing volume by name to server idempotence
110 cloudscale_ch.cloud.volume:
111 name: '{{ cloudscale_resource_prefix }}-vol'
112 servers:
113 - '{{ server.uuid }}'
114 register: vol
115 - name: 'VERIFY: Attach existing volume by name to server idempotence'
116 assert:
117 that:
118 - vol is successful
119 - vol is not changed
120 - server.uuid in vol.servers | map(attribute="uuid")
121
122 - name: Fail revert attached volume to snapshot
123 cloudscale_ch.cloud.volume:
124 uuid: '{{ vol.uuid }}'
125 revert: '{{ vol_snap_first.uuid }}'
126 register: revert
127 ignore_errors: True
128 - name: 'VERIFY: Fail revert attached volume to snapshot'
129 assert:
130 that:
131 - revert is failed
132
133 - name: Delete snapshot
134 cloudscale_ch.cloud.volume_snapshot:
135 uuid: '{{ vol_snap_first.uuid }}'
136 state: absent
137
138 - name: Resize attached volume by UUID in check mode
139 cloudscale_ch.cloud.volume:
140 uuid: '{{ vol.uuid }}'
141 size_gb: 100
142 check_mode: yes
143 register: vol
144 - name: 'VERIFY: Resize attached volume by UUID in check mode'
145 assert:
146 that:
147 - vol is successful
148 - vol is changed
149 - vol.size_gb == 50
150
151 - name: Resize attached volume by UUID
152 cloudscale_ch.cloud.volume:
153 uuid: '{{ vol.uuid }}'
154 size_gb: 100
155 register: vol
156 - name: 'VERIFY: Resize attached volume by UUID'
157 assert:
158 that:
159 - vol is successful
160 - vol is changed
161 - vol.size_gb == 100
162
163 - name: Resize attached volume by UUID idempotence
164 cloudscale_ch.cloud.volume:
165 uuid: '{{ vol.uuid }}'
166 size_gb: 100
167 register: vol
168 - name: 'VERIFY: Resize attached volume by UUID idempotence'
169 assert:
170 that:
171 - vol is successful
172 - vol is not changed
173 - vol.size_gb == 100
174
175 - name: Delete attached volume by UUID in check mode
176 cloudscale_ch.cloud.volume:
177 uuid: '{{ vol.uuid }}'
178 state: 'absent'
179 check_mode: yes
180 register: deleted
181 - name: 'VERIFY: Delete attached volume by UUID in check mode'
182 assert:
183 that:
184 - deleted is successful
185 - deleted is changed
186 - deleted.state == 'present'
187 - deleted.uuid == vol.uuid
188 - deleted.name == cloudscale_resource_prefix + '-vol'
189
190 - name: Delete attached volume by UUID
191 cloudscale_ch.cloud.volume:
192 uuid: '{{ vol.uuid }}'
193 state: 'absent'
194 register: deleted
195 - name: 'VERIFY: Delete attached volume by UUID'
196 assert:
197 that:
198 - deleted is successful
199 - deleted is changed
200 - deleted.state == 'absent'
201 - deleted.uuid == vol.uuid
202 - deleted.name == cloudscale_resource_prefix + '-vol'
203
204 - name: Delete attached volume by UUID idempotence
205 cloudscale_ch.cloud.volume:
206 uuid: '{{ vol.uuid }}'
207 state: 'absent'
208 register: deleted
209 - name: 'VERIFY: Delete attached volume by UUID idempotence'
210 assert:
211 that:
212 - deleted is successful
213 - deleted is not changed
214 - deleted.state == 'absent'
215 - deleted.uuid == vol.uuid
216 - not deleted.name
217
218 - name: Create bulk volume and attach
219 cloudscale_ch.cloud.volume:
220 name: '{{ cloudscale_resource_prefix }}-bulk'
221 type: bulk
222 zone: '{{ cloudscale_test_zone }}'
223 size_gb: 100
224 servers:
225 - '{{ server.uuid }}'
226 register: bulk
227 - name: 'VERIFY: Create bulk volume and attach'
228 assert:
229 that:
230 - bulk is successful
231 - bulk is changed
232 - bulk.size_gb == 100
233 - server.uuid in bulk.servers | map(attribute="uuid")
234
235 - name: Detach volume by UUID
236 cloudscale_ch.cloud.volume:
237 uuid: '{{ bulk.uuid }}'
238 servers: []
239 register: bulk
240 - name: 'VERIFY: Detach volume by UUID'
241 assert:
242 that:
243 - bulk is successful
244 - bulk is changed
245 - bulk.servers == []
246
247 - name: Resize detached volume by name
248 cloudscale_ch.cloud.volume:
249 name: '{{ bulk.name }}'
250 size_gb: 200
251 register: bulk
252 - name: 'VERIFY: Resize detached volume by name'
253 assert:
254 that:
255 - bulk is successful
256 - bulk is changed
257 - bulk.size_gb == 200
258
259 - name: Delete volume by name in check mode
260 cloudscale_ch.cloud.volume:
261 name: '{{ bulk.name }}'
262 state: 'absent'
263 check_mode: yes
264 register: bulk
265 - name: 'VERIFY: Delete volume by name'
266 assert:
267 that:
268 - bulk is successful
269 - bulk is changed
270 - bulk.state == 'present'
271
272 - name: Delete volume by name
273 cloudscale_ch.cloud.volume:
274 name: '{{ bulk.name }}'
275 state: 'absent'
276 register: bulk
277 - name: 'VERIFY: Delete volume by name'
278 assert:
279 that:
280 - bulk is successful
281 - bulk is changed
282 - bulk.state == 'absent'
283
284 - name: Delete volume by name idempotence
285 cloudscale_ch.cloud.volume:
286 name: '{{ bulk.name }}'
287 state: 'absent'
288 register: bulk
289 - name: 'VERIFY: Delete volume by name idempotence'
290 assert:
291 that:
292 - bulk is successful
293 - bulk is not changed
294 - bulk.state == 'absent'
295
296 - name: Stop test server
297 cloudscale_ch.cloud.server:
298 uuid: '{{ server.uuid }}'
299 state: stopped
300 register: server_stopped
301
302 - name: Revert root volume of stopped server
303 cloudscale_ch.cloud.volume:
304 uuid: '{{ server.volumes.0.uuid }}'
305 revert: '{{ root_volume_snapshot.uuid }}'
306 register: revert_root_volume
307 - name: 'VERIFY: Revert root volume of stopped server'
308 assert:
309 that:
310 - revert_root_volume is successful
311 - revert_root_volume is changed