forked from hicknhack-software/ansible-libvirt
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathimage.yml
31 lines (27 loc) · 907 Bytes
/
image.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
- name: Ensure image path exists
file:
path: "{{ image_download_path }}"
state: directory
recurse: yes
- name: Check if image is already downloaded
stat:
path: "{{ image_download_path }}/{{ libvirt_image_dist }}"
register: download
- block:
- name: download image disk
get_url:
url: "{{ libvirt_domain.image_url }}"
dest: "{{ image_download_path }}/{{ libvirt_image_dist }}"
register: download_result
- name: remove modified image
file:
path: "{{ image_download_path }}/{{ libvirt_image_name }}"
state: absent
when: download_result.changed
when: download.stat.exists == False
- name: convert the image
command: "qemu-img convert -O qcow2 {{ libvirt_image_dist }} {{ libvirt_images_path }}/{{ libvirt_image_name }}"
args:
chdir: "{{ image_download_path }}"
creates: "{{ libvirt_images_path }}/{{ libvirt_image_name }}"