Skip to content

Commit

Permalink
Use block/rescue for error handling
Browse files Browse the repository at this point in the history
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
(cherry picked from commit e9c9e37)
  • Loading branch information
Jesse Pretorius committed Aug 11, 2017
1 parent 43bd5c3 commit 62ecbd9
Showing 1 changed file with 34 additions and 33 deletions.
67 changes: 34 additions & 33 deletions tasks/ceph_preinstall_apt.yml
Expand Up @@ -23,40 +23,41 @@
tags:
- ceph-apt-keys

- name: Add ceph apt-keys
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.keyserver | default(omit) }}"
data: "{{ item.data | default(omit) }}"
url: "{{ item.url | default(omit) }}"
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'
tags:
- ceph-apt-keys
- block:
- name: Add ceph apt-keys (primary keyserver)
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.keyserver | default(omit) }}"
data: "{{ item.data | default(omit) }}"
url: "{{ item.url | default(omit) }}"
state: "present"
register: add_keys
until: add_keys|success
retries: 5
delay: 2
with_items: "{{ ceph_gpg_keys }}"
when: ceph_pkg_source == 'ceph'
tags:
- ceph-apt-keys

- name: Add ceph apt-keys using fallback keyserver
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.fallback_keyserver | default(omit) }}"
url: "{{ item.fallback_url | default(omit) }}"
state: "present"
register: add_keys_fallback
until: add_keys_fallback|success
retries: 5
delay: 2
with_items: "{{ ceph_gpg_keys }}"
when: ceph_pkg_source == 'ceph' and
add_keys|failed and
(item.fallback_keyserver is defined or
item.fallback_url is defined)
tags:
- ceph-apt-keys
rescue:
- name: Add ceph apt-keys (fallback keyserver)
apt_key:
id: "{{ item.hash_id }}"
keyserver: "{{ item.fallback_keyserver | default(omit) }}"
url: "{{ item.fallback_url | default(omit) }}"
state: "present"
register: add_keys_fallback
until: add_keys_fallback|success
retries: 5
delay: 2
with_items: "{{ ceph_gpg_keys }}"
when:
- ceph_pkg_source == 'ceph'
- (item.fallback_keyserver is defined or
item.fallback_url is defined)
tags:
- ceph-apt-keys

- name: add ubuntu cloud archive key package
apt:
Expand Down

0 comments on commit 62ecbd9

Please sign in to comment.