Use block/rescue for error handling
Instead of allowing the first task to fail, then using the fallback - use block/rescue to achieve the same, but totally skip the second task if the first succeeds. Change-Id: Icb4ce1901a5a4c2b870b308f7cd6444b304a022a
This commit is contained in:
parent
d4906271ce
commit
e9c9e37bc7
@ -23,6 +23,8 @@
|
||||
- ceph_pkg_source == 'ceph'
|
||||
|
||||
- name: Add ceph apt-keys
|
||||
block:
|
||||
- name: Add keys (primary keyserver)
|
||||
apt_key:
|
||||
id: "{{ item.hash_id }}"
|
||||
keyserver: "{{ item.keyserver | default(omit) }}"
|
||||
@ -31,14 +33,14 @@
|
||||
state: "present"
|
||||
register: add_keys
|
||||
until: add_keys|success
|
||||
failed_when: false
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ ceph_gpg_keys }}"
|
||||
when:
|
||||
- ceph_pkg_source == 'ceph'
|
||||
|
||||
- name: Add ceph apt-keys using fallback keyserver
|
||||
rescue:
|
||||
- name: Add keys (fallback keyserver)
|
||||
apt_key:
|
||||
id: "{{ item.hash_id }}"
|
||||
keyserver: "{{ item.fallback_keyserver | default(omit) }}"
|
||||
@ -50,8 +52,7 @@
|
||||
delay: 2
|
||||
with_items: "{{ ceph_gpg_keys }}"
|
||||
when:
|
||||
- ceph_pkg_source | lower == 'ceph'
|
||||
- add_keys | failed
|
||||
- ceph_pkg_source == 'ceph'
|
||||
- item.fallback_keyserver is defined or item.fallback_url is defined
|
||||
|
||||
- name: add ubuntu cloud archive key package
|
||||
@ -60,7 +61,7 @@
|
||||
state: "{{ ceph_client_package_state }}"
|
||||
register: add_keys
|
||||
when:
|
||||
- ceph_pkg_source | lower == 'uca'
|
||||
- ceph_pkg_source == 'uca'
|
||||
|
||||
- name: Add ceph repo(s)
|
||||
apt_repository:
|
||||
|
Loading…
Reference in New Issue
Block a user