Skip to content

Commit 9fab5e6

Browse files
authored
Merge pull request #72 from roumano/get_url_checksum
Add a option to use checksum on get_url in tasks Ensure remote images are downloaded
2 parents 8d8c78c + 49a27a2 commit 9fab5e6

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ Role Variables
112112
`libvirt_volume_default_format` are valid here. Default is
113113
`libvirt_volume_default_format`.
114114
- `image`: (optional) a URL to an image with which the volume is initalised (full copy).
115+
- `checksum`: (optional) checksum of the `image` to avoid download when it's not necessary.
115116
- `backing_image`: (optional) name of the backing volume which is assumed to already be the same pool (copy-on-write).
116117
- `image` and `backing_image` are mutually exclusive options.
117118
- `target`: (optional) Manually influence type and order of volumes

tasks/volumes.yml

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
---
22
- name: Ensure remote images are downloaded
33
get_url:
4-
url: "{{ item }}"
5-
dest: "{{ libvirt_vm_image_cache_path }}/{{ item | basename }}"
6-
with_items: "{{ volumes | selectattr('image', 'defined') | map(attribute='image') | list }}"
7-
when: "'http' in item"
4+
url: "{{ item.image }}"
5+
dest: "{{ libvirt_vm_image_cache_path }}/{{ item.image | basename }}"
6+
checksum: "{{ item.checksum | default(omit) }}"
7+
with_items: "{{ volumes | selectattr('image', 'defined') | list }}"
8+
when: "'http' in item.image"
89

910
- name: Ensure local images are copied
1011
copy:
11-
src: "{{ item }}"
12-
dest: "{{ libvirt_vm_image_cache_path }}/{{ item | basename }}"
13-
with_items: "{{ volumes | selectattr('image', 'defined') | map(attribute='image') | list }}"
14-
when: "'http' not in item"
12+
src: "{{ item.image }}"
13+
dest: "{{ libvirt_vm_image_cache_path }}/{{ item.image | basename }}"
14+
checksum: "{{ item.checksum | default(omit) }}"
15+
with_items: "{{ volumes | selectattr('image', 'defined') | list }}"
16+
when: "'http' not in item.image"
1517

1618
- name: Ensure the VM disk volumes exist
1719
script: >

0 commit comments

Comments
 (0)