kayobe/ansible/roles/image-download/tasks/main.yml
Will Szumski dea36ac9d2 Fix issue with image download when checksum url is none
TASK [image-download : Ensure the image is downloaded] *************************
task path: /home/zuul/kayobe-venv/share/kayobe/ansible/roles/image-download/tasks/main.yml:19
fatal: [localhost]: FAILED! => {
    "msg": "The field 'vars' has an invalid value, which includes an undefined variable. The error was: 'dict object' has no attribute 'content'\n\nThe error appears to have been in '/home/zuul/kayobe-venv/share/kayobe/ansible/roles/image-download/tasks/main.yml': line 19, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n    - name: Ensure the image is downloaded\n      ^ here\n"
}
	to retry, use: --limit @/home/zuul/kayobe-venv/share/kayobe/ansible/kolla-openstack.retry

PLAY RECAP *********************************************************************
controller0                : ok=3    changed=0    unreachable=0    failed=0
localhost                  : ok=6    changed=2    unreachable=0    failed=1

Change-Id: I45fb193b423c7e874aa70cd5f0252e0b0f4e2f05
Story: 2006715
Task: 37086
2019-10-14 12:24:44 +00:00

44 lines
1.6 KiB
YAML

---
- block:
- block:
- name: Fail if the checksum algorithm is not set
fail:
msg: "Checksum algorithm for image {{ image_download_url }} not set"
when: image_download_checksum_algorithm is none or
image_download_checksum_algorithm == ""
- name: Get the expected checksum
uri:
url: "{{ image_download_checksum_url }}"
return_content: true
register: expected_checksum
when:
- image_download_checksum_url is not none
- image_download_checksum_url != ""
- name: Ensure the image is downloaded
vars:
# NOTE(wszumski): This is evaluated even when expected_checksum is skipped
checksum: "{{ image_download_checksum_algorithm }}:{{ expected_checksum.content.split(' ')[0] if 'content' in expected_checksum else '' }}"
get_url:
url: "{{ image_download_url }}"
dest: "{{ image_download_dest }}"
mode: 0640
# If the file exists locally, its checksum will be compared with this.
checksum: "{{ checksum if expected_checksum is not skipped else omit }}"
# Always download the image if we have no checksum to compare with.
force: "{{ expected_checksum is skipped }}"
backup: true
when:
- image_download_url is not none
- image_download_url != ""
- name: Ensure the local image is copied
copy:
src: "{{ image_download_path }}"
dest: "{{ image_download_dest }}"
mode: 0640
when:
- image_download_path is not none
- image_download_path != ""