31 lines
1.0 KiB
YAML
31 lines
1.0 KiB
YAML
---
|
|
- name: Ensure remote images are downloaded
|
|
get_url:
|
|
url: "{{ item }}"
|
|
dest: "{{ libvirt_vm_image_cache_path }}/{{ item | basename }}"
|
|
with_items: "{{ libvirt_vm_volumes | selectattr('image', 'defined') | map(attribute='image') | list }}"
|
|
when: "{{ 'http' in item }}"
|
|
|
|
- name: Ensure local images are copied
|
|
copy:
|
|
src: "{{ item }}"
|
|
dest: "{{ libvirt_vm_image_cache_path }}/{{ item | basename }}"
|
|
with_items: "{{ libvirt_vm_volumes | selectattr('image', 'defined') | map(attribute='image') | list }}"
|
|
when: "{{ 'http' not in item }}"
|
|
|
|
- name: Ensure the VM volumes exist
|
|
script: >
|
|
virt_volume.sh
|
|
{{ item.name }}
|
|
{{ item.pool }}
|
|
{{ item.capacity }}
|
|
{{ item.format | default('qcow2') }}
|
|
{% if item.image is defined %}
|
|
{{ libvirt_vm_image_cache_path }}/{{ item.image | basename }}
|
|
{% endif %}
|
|
with_items: "{{ libvirt_vm_volumes }}"
|
|
register: volume_result
|
|
changed_when:
|
|
- "{{ volume_result | success }}"
|
|
- "{{ (volume_result.stdout | from_json).changed | default(True) }}"
|