diff options
Diffstat (limited to 'src/three-minute-demo/roles/build-image')
-rw-r--r-- | src/three-minute-demo/roles/build-image/defaults/main.yaml | 3 | ||||
-rw-r--r-- | src/three-minute-demo/roles/build-image/tasks/main.yaml | 19 |
2 files changed, 22 insertions, 0 deletions
diff --git a/src/three-minute-demo/roles/build-image/defaults/main.yaml b/src/three-minute-demo/roles/build-image/defaults/main.yaml new file mode 100644 index 0000000..b6283b8 --- /dev/null +++ b/src/three-minute-demo/roles/build-image/defaults/main.yaml | |||
@@ -0,0 +1,3 @@ | |||
1 | distro: debian | ||
2 | image_formats: | ||
3 | - qcow2 | ||
diff --git a/src/three-minute-demo/roles/build-image/tasks/main.yaml b/src/three-minute-demo/roles/build-image/tasks/main.yaml new file mode 100644 index 0000000..57be287 --- /dev/null +++ b/src/three-minute-demo/roles/build-image/tasks/main.yaml | |||
@@ -0,0 +1,19 @@ | |||
1 | - block: | ||
2 | |||
3 | - name: Check for existing image | ||
4 | stat: | ||
5 | path: "{{ distro }}.{{ image_formats[0] }}" | ||
6 | register: image_file | ||
7 | |||
8 | - name: Build image | ||
9 | command: | | ||
10 | disk-image-create -o {{ distro }} -t {{ image_formats | join(',') }} {{ distro }}-minimal simple-init growroot | ||
11 | when: not image_file.stat.exists | ||
12 | |||
13 | - rescue: | ||
14 | |||
15 | - name: Clean up after a build failure | ||
16 | file: | ||
17 | path: "{{ distro }}.{{ item }}" | ||
18 | state: absent | ||
19 | with_items: "{{ image_formats }}" | ||