|
10 | 10 | image_remove_old: false |
11 | 11 |
|
12 | 12 | tasks: |
13 | | - # # ------------------------------------------------------ |
| 13 | + # ------------------------------------------------------ |
14 | 14 | - name: Download Virtual Disk {{ image_filename }} from URL |
15 | 15 | ansible.builtin.get_url: # TODO: what if file doesn't download completely? |
16 | 16 | url: "{{ image_url }}" |
17 | 17 | dest: /tmp/{{ image_filename }} |
18 | 18 |
|
19 | | - - name: Get the Virtual Disk size |
20 | | - ansible.builtin.stat: |
21 | | - path: /tmp/{{ image_filename }} |
22 | | - register: disk_file_info |
23 | | - |
24 | | - # TODO |
25 | | - # - name: (Optionally) remove existing Virtual Disk {{ image_filename }} from HyperCore |
26 | | - # scale_computing.hypercore.api: |
27 | | - # action: get |
28 | | - # cluster_instance: |
29 | | - # host: "{{ sc_host }}" |
30 | | - # username: "{{ sc_username }}" |
31 | | - # password: "{{ sc_password }}" |
32 | | - # endpoint: "/rest/v1/VirtualDisk" |
33 | | - # register: virtualDiskResult |
| 19 | + - name: (Optionally) remove existing Virtual Disk {{ image_filename }} from HyperCore |
| 20 | + when: image_remove_old | bool |
| 21 | + scale_computing.hypercore.virtual_disk: |
| 22 | + name: "{{ item }}" |
| 23 | + state: absent |
| 24 | + loop: |
| 25 | + - "uploading-{{ image_filename }}" |
| 26 | + - "{{ image_filename }}" |
34 | 27 |
|
35 | 28 | # ------------------------------------------------------ |
36 | 29 | - name: Upload Virtual Disk {{ image_filename }} to HyperCore |
37 | | - scale_computing.hypercore.api: |
38 | | - action: put |
39 | | - endpoint: /rest/v1/VirtualDisk/upload |
40 | | - data: |
41 | | - filename: "{{ image_filename }}" |
42 | | - filesize: "{{ disk_file_info.stat.size }}" |
| 30 | + scale_computing.hypercore.virtual_disk: |
43 | 31 | source: /tmp/{{ image_filename }} |
44 | | - register: uploadResult |
| 32 | + name: "{{ image_filename }}" |
| 33 | + state: present |
45 | 34 |
|
46 | 35 | # ------------------------------------------------------ |
47 | 36 | - name: Get Information About the uploaded Virtual Disk in HyperCore |
48 | | - scale_computing.hypercore.api: |
49 | | - action: get |
50 | | - endpoint: /rest/v1/VirtualDisk/{{ uploadResult.record.createdUUID }} |
| 37 | + scale_computing.hypercore.virtual_disk_info: |
| 38 | + name: "{{ image_filename }}" |
51 | 39 | register: result |
52 | 40 |
|
53 | 41 | - name: Show uploaded disk info |
54 | 42 | debug: |
55 | | - var: result.record[0] |
| 43 | + var: result.records[0] |
0 commit comments