diff options
Diffstat (limited to 'src/three-minute-demo/roles/upload-image')
| -rw-r--r-- | src/three-minute-demo/roles/upload-image/defaults/main.yaml | 3 | ||||
| -rw-r--r-- | src/three-minute-demo/roles/upload-image/tasks/main.yaml | 25 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/three-minute-demo/roles/upload-image/defaults/main.yaml b/src/three-minute-demo/roles/upload-image/defaults/main.yaml new file mode 100644 index 0000000..b6283b8 --- /dev/null +++ b/src/three-minute-demo/roles/upload-image/defaults/main.yaml | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | distro: debian | ||
| 2 | image_formats: | ||
| 3 | - qcow2 | ||
diff --git a/src/three-minute-demo/roles/upload-image/tasks/main.yaml b/src/three-minute-demo/roles/upload-image/tasks/main.yaml new file mode 100644 index 0000000..c14c7eb --- /dev/null +++ b/src/three-minute-demo/roles/upload-image/tasks/main.yaml | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | # All three are marked no_log because auth info from clouds.yaml is being | ||
| 2 | # extracted and passed around | ||
| 3 | |||
| 4 | - name: Check for existing images | ||
| 5 | os_image_facts: | ||
| 6 | cloud: "{{ item.name }}" | ||
| 7 | region_name: "{{ item.region_name }}" | ||
| 8 | image: "three-minute-demo-image" | ||
| 9 | with_items: "{{ openstack.clouds }}" | ||
| 10 | no_log: true | ||
| 11 | register: image_records | ||
| 12 | |||
| 13 | - name: Get list of clouds without image | ||
| 14 | set_fact: | ||
| 15 | clouds_without_image: "{{ image_records.results|json_query('[?ansible_facts.openstack_image==null].item') }}" | ||
| 16 | no_log: true | ||
| 17 | |||
| 18 | - name: Upload image if it's not there | ||
| 19 | os_image: | ||
| 20 | cloud: "{{ item.name }}" | ||
| 21 | region_name: "{{ item.region_name }}" | ||
| 22 | name: "three-minute-demo-image" | ||
| 23 | filename: "{{ distro }}.{{ item.image_format }}" | ||
| 24 | no_log: true | ||
| 25 | with_items: "{{ clouds_without_image }}" | ||
