Debian Codegraph @

ansible_collections/community/vmware/tests/integration/targets/vsphere_file/tasks/main.yml

raw
1 - set_fact:
2 file: '/ansible_test_file.txt'
3 directory: '/ansible_test_directory/'
4 vsphere_connection: &vsphere_conn
5 host: '{{ vcenter_ipaddress }}'
6 username: '{{ vcenter_username }}'
7 password: '{{ vcenter_password }}'
8 datacenter: '{{ vcenter_datacenter }}'
9 datastore: '{{ vcenter_datastore }}'
10 validate_certs: false
11
12 - set_fact:
13 vsphere_conection_file: &vsphere_conn_file
14 <<: *vsphere_conn
15 path: '{{ file }}'
16 vsphere_conection_dir: &vsphere_conn_dir
17 <<: *vsphere_conn
18 path: '{{ directory }}'
19
20 # Clean up environment
21 - name: Delete file
22 vsphere_file:
23 <<: *vsphere_conn_file
24 state: absent
25 ignore_errors: true
26
27 - name: Delete directory
28 vsphere_file:
29 <<: *vsphere_conn_dir
30 state: absent
31 ignore_errors: true
32
33 # Test file operations
34 - name: Test file at start (check_mode)
35 vsphere_file:
36 <<: *vsphere_conn_file
37 state: file
38 check_mode: true
39 ignore_errors: true
40 register: cm_test_file_start
41
42 - name: Verify cm_test_file_start
43 assert:
44 that:
45 - cm_test_file_start is failed
46 - cm_test_file_start.state == 'absent'
47 - cm_test_file_start.status == 404
48
49 - name: Test file at start (normal mode)
50 vsphere_file:
51 <<: *vsphere_conn_file
52 state: file
53 register: nm_test_file_start
54 ignore_errors: true
55
56 - name: Verify nm_test_file_start
57 assert:
58 that:
59 - nm_test_file_start is failed
60 - nm_test_file_start.state == 'absent'
61 - nm_test_file_start.status == 404
62
63 - name: Touch file (check_mode)
64 vsphere_file:
65 <<: *vsphere_conn_file
66 state: touch
67 check_mode: true
68 register: cm_touch_file
69
70 - name: Verify cm_touch_file
71 assert:
72 that:
73 - cm_touch_file is success
74 - cm_touch_file is changed
75 - cm_touch_file.reason == 'Created'
76 - cm_touch_file.size == 0
77 #- cm_touch_file.state == 'file' # FIXME
78 - cm_touch_file.status == 201
79
80 - name: Touch file (normal mode)
81 vsphere_file:
82 <<: *vsphere_conn_file
83 state: touch
84 register: nm_touch_file
85
86 - name: Verify nm_touch_file
87 assert:
88 that:
89 - nm_touch_file is success
90 - nm_touch_file is changed
91 - nm_touch_file.reason == 'Created'
92 - nm_touch_file.size == 0
93 #- nm_touch_file.state == 'file' # FIXME
94 - nm_touch_file.status == 201
95
96 - name: Test file after touch (check_mode)
97 vsphere_file:
98 <<: *vsphere_conn_file
99 state: file
100 check_mode: true
101 register: cm_test_file_touch
102
103 - name: Verify cm_test_file_touch
104 assert:
105 that:
106 - cm_test_file_touch is success
107 - cm_test_file_touch is not changed
108 - cm_test_file_touch.size == 0
109 #- cm_test_file_touch.state == 'file' # FIXME
110 - cm_test_file_touch.status == 200
111
112 - name: Test file after touch (normal mode)
113 vsphere_file:
114 <<: *vsphere_conn_file
115 state: file
116 register: nm_test_file_touch
117
118 - name: Verify nm_test_file_touch
119 assert:
120 that:
121 - nm_test_file_touch is success
122 - nm_test_file_touch is not changed
123 - nm_test_file_touch.size == 0
124 #- nm_test_file_touch.state == 'file' # FIXME
125 - nm_test_file_touch.status == 200
126
127 - name: Delete file (check_mode)
128 vsphere_file:
129 <<: *vsphere_conn_file
130 state: absent
131 check_mode: true
132 register: cm_delete_file
133
134 - name: Verify cm_delete_file
135 assert:
136 that:
137 - cm_delete_file is success
138 - cm_delete_file is changed
139 - cm_delete_file.reason == 'No Content'
140 - cm_delete_file.size == None
141 - cm_delete_file.state == 'absent'
142 - cm_delete_file.status == 204
143
144 - name: Delete file (normal mode)
145 vsphere_file:
146 <<: *vsphere_conn_file
147 state: absent
148 register: nm_delete_file
149
150 - name: Verify nm_delete_file
151 assert:
152 that:
153 - nm_delete_file is success
154 - nm_delete_file is changed
155 - nm_delete_file.reason == 'No Content'
156 - nm_delete_file.size == None
157 - nm_delete_file.state == 'absent'
158 - nm_delete_file.status == 204
159
160 - name: Test file after delete (check_mode)
161 vsphere_file:
162 <<: *vsphere_conn_file
163 state: file
164 check_mode: true
165 ignore_errors: true
166 register: cm_test_file_delete
167
168 - name: Verify cm_test_file_delete
169 assert:
170 that:
171 - cm_test_file_delete is failed
172 - cm_test_file_delete.size == None
173 - cm_test_file_delete.state == 'absent'
174 - cm_test_file_delete.status == 404
175
176 - name: Test file after delete (normal mode)
177 vsphere_file:
178 <<: *vsphere_conn_file
179 state: file
180 ignore_errors: true
181 register: nm_test_file_delete
182
183 - name: Verify nm_test_file_delete
184 assert:
185 that:
186 - nm_test_file_delete is failed
187 - nm_test_file_delete.size == None
188 - nm_test_file_delete.state == 'absent'
189 - nm_test_file_delete.status == 404
190
191 # Test directory operations
192 - name: Test directory at start (check_mode)
193 vsphere_file:
194 <<: *vsphere_conn_dir
195 state: file
196 check_mode: true
197 ignore_errors: true
198 register: cm_test_dir_start
199
200 - name: Verify cm_test_dir_start
201 assert:
202 that:
203 - cm_test_dir_start is failed
204 - cm_test_dir_start.size == None
205 - cm_test_dir_start.state == 'absent'
206 - cm_test_dir_start.status == 404
207
208 - name: Test directory at start (normal mode)
209 vsphere_file:
210 <<: *vsphere_conn_dir
211 state: file
212 ignore_errors: true
213 register: nm_test_dir_start
214
215 # NOTE: Deleting directories is not implemented.
216 - name: Verify nm_test_dir_start
217 assert:
218 that:
219 - nm_test_dir_start is failed
220 - nm_test_dir_start.size == None
221 - nm_test_dir_start.state == 'absent'
222 - nm_test_dir_start.status == 404
223
224 - name: Create directory (check_mode)
225 vsphere_file:
226 <<: *vsphere_conn_dir
227 path: '{{ directory }}'
228 state: directory
229 check_mode: true
230 register: cm_create_dir
231
232 - name: Verify cm_create_dir
233 assert:
234 that:
235 - cm_create_dir is success
236 - cm_create_dir is changed
237 - cm_create_dir.reason == 'Created'
238 - cm_create_dir.size == None
239 #- cm_create_dir.state == 'directory' # FIXME
240 - cm_create_dir.status == 201
241
242 - name: Create directory (normal mode)
243 vsphere_file:
244 <<: *vsphere_conn_dir
245 path: '{{ directory }}'
246 state: directory
247 register: nm_create_dir
248
249 - name: Verify nm_create_dir
250 assert:
251 that:
252 - nm_create_dir is success
253 - nm_create_dir is changed
254 - nm_create_dir.reason == 'Created'
255 - nm_create_dir.size == None
256 #- nm_create_dir.state == 'directory' # FIXME
257 - nm_create_dir.status == 201
258
259 - name: Test directory after create (check_mode)
260 vsphere_file:
261 <<: *vsphere_conn_dir
262 path: '{{ directory }}'
263 state: file
264 check_mode: true
265 register: cm_test_dir_create
266
267 - name: Verify cm_test_dir_create
268 assert:
269 that:
270 - cm_test_dir_create is success
271 - cm_test_dir_create is not changed
272 #- cm_test_dir_create.size == 0
273 #- cm_test_dir_create.state == 'file' # FIXME
274 - cm_test_dir_create.status == 200
275
276 - name: Test directory after create (normal mode)
277 vsphere_file:
278 <<: *vsphere_conn_dir
279 path: '{{ directory }}'
280 state: file
281 register: nm_test_dir_create
282
283 - name: Verify nm_test_dir_create
284 assert:
285 that:
286 - nm_test_dir_create is success
287 - nm_test_dir_create is not changed
288 #- nm_test_dir_create.size == 0
289 #- nm_test_dir_create.state == 'file' # FIXME
290 - nm_test_dir_create.status == 200
291
292 - name: Delete directory (check_mode)
293 vsphere_file:
294 <<: *vsphere_conn_dir
295 state: absent
296 check_mode: true
297 ignore_errors: true
298 register: cm_delete_dir
299
300 - name: Verify cm_delete_dir
301 assert:
302 that:
303 - cm_delete_dir is success
304 - cm_delete_dir is changed
305 - cm_delete_dir.reason == 'No Content'
306 - cm_delete_dir.size == None
307 - cm_delete_dir.state == 'absent'
308 - cm_delete_dir.status == 204
309
310 - name: Delete directory (normal mode)
311 vsphere_file:
312 <<: *vsphere_conn_dir
313 path: '{{ directory }}'
314 state: absent
315 ignore_errors: true
316 register: nm_delete_dir
317
318 # NOTE: Deleting directories is not implemented
319 - name: Verify nm_delete_dir
320 assert:
321 that:
322 - nm_delete_dir is failed # FIXME
323 #- nm_delete_dir is success
324 #- nm_delete_dir is changed
325 - nm_delete_dir.reason == 'Method Not Allowed' # FIXME
326 #- cm_delete_dir.reason == 'No Content'
327 #- nm_delete_dir.size == None
328 #- cm_delete_dir.state == 'absent'
329 - nm_delete_dir.status == 405 # FIXME
330 #- cm_delete_dir.status == 204
331
332 - name: Test directory after delete (check_mode)
333 vsphere_file:
334 <<: *vsphere_conn_dir
335 path: '{{ directory }}'
336 state: file
337 check_mode: true
338 ignore_errors: true
339 register: cm_test_dir_delete
340
341 - name: Verify cm_test_dir_delete
342 assert:
343 that:
344 - cm_test_dir_delete is success # FIXME
345 - cm_test_dir_delete is not changed #FIXME
346 #- cm_test_dir_delete is failed
347 #- cm_test_dir_delete.size == None
348 #- cm_test_dir_delete.state == 'file'
349 - cm_test_dir_delete.status == 200 # FIXME
350 #- nm_test_dir_delete.status == 404
351
352 - name: Test directory after delete (normal mode)
353 vsphere_file:
354 <<: *vsphere_conn_dir
355 path: '{{ directory }}'
356 state: file
357 ignore_errors: true
358 register: nm_test_dir_delete
359
360 - name: Verify nm_test_dir_delete
361 assert:
362 that:
363 - nm_test_dir_delete is success # FIXME
364 - nm_test_dir_delete is not changed #FIXME
365 #- nm_test_dir_delete is failed
366 #- nm_test_dir_delete.size == None
367 #- nm_test_dir_delete.state == 'file'
368 - nm_test_dir_delete.status == 200 # FIXME
369 #- nm_test_dir_delete.status == 404