Use block/rescue for image pre-stage

Move to usage of block/rescue for image pre-stage step.

Change-Id: I4ec91f541e6d2d4cca4d899f4c7d519b169e2f50
Co-Authored-By: Jesse Pretorius <jesse@odyssey4.me>
This commit is contained in:
Dmitriy Rabotjagov 2019-05-13 17:45:00 +03:00 committed by Dmitriy Rabotyagov (noonedeadpunk)
parent d22a541395
commit b393915874
2 changed files with 38 additions and 40 deletions

View File

@ -23,26 +23,25 @@
when:
- lxc_image_cache_refresh | bool
- name: Ensure image has been pre-staged
async_status:
jid: "{{ prestage_image.ansible_job_id }}"
register: job_result
until: job_result.finished
ignore_errors: true
retries: 60
- name: Trying to download image with alternate method
get_url:
url: "{{ lxc_hosts_container_image_url }}"
dest: "/tmp/{{ cache_basename }}"
validate_certs: "{{ (lxc_hosts_validate_certs | bool) | lower }}"
force: true
timeout: 15
register: image_download
until: image_download is success
retries: 3
delay: 2
when: job_result.failed
- block:
- name: Ensure image has been pre-staged
async_status:
jid: "{{ prestage_image.ansible_job_id }}"
register: job_result
until: job_result.finished
retries: 60
rescue:
- name: Trying to download image with alternate method
get_url:
url: "{{ lxc_hosts_container_image_url }}"
dest: "/tmp/{{ cache_basename }}"
validate_certs: "{{ (lxc_hosts_validate_certs | bool) | lower }}"
force: true
timeout: 15
register: image_download
until: image_download is success
retries: 3
delay: 2
- name: Ensure systemd-importd is enabled
systemd:

View File

@ -32,26 +32,25 @@
when:
- lxc_image_cache_refresh | bool
- name: Ensure image has been pre-staged
async_status:
jid: "{{ prestage_image.ansible_job_id }}"
register: job_result
until: job_result.finished
ignore_errors: true
retries: 60
- name: Trying to download image with alternate method
get_url:
url: "{{ lxc_hosts_container_image_url }}"
dest: "/tmp/{{ cache_basename }}"
validate_certs: "{{ (lxc_hosts_validate_certs | bool) | lower }}"
force: true
timeout: 15
register: image_download
until: image_download is success
retries: 3
delay: 2
when: job_result.failed
- block:
- name: Ensure image has been pre-staged
async_status:
jid: "{{ prestage_image.ansible_job_id }}"
register: job_result
until: job_result.finished
retries: 60
rescue:
- name: Trying to download image with alternate method
get_url:
url: "{{ lxc_hosts_container_image_url }}"
dest: "/tmp/{{ cache_basename }}"
validate_certs: "{{ (lxc_hosts_validate_certs | bool) | lower }}"
force: true
timeout: 15
register: image_download
until: image_download is success
retries: 3
delay: 2
- name: Place container rootfs
unarchive: