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: Ida644fee4f9842a45bf273db379b00df12bec695
(cherry picked from commit 3ebde68b53
)
This commit is contained in:
parent
8d5df339dd
commit
9106e4f2d4
@ -30,36 +30,38 @@
|
||||
tags:
|
||||
- galera-apt-packages
|
||||
|
||||
- name: Add galera 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: "{{ galera_gpg_keys }}"
|
||||
tags:
|
||||
- galera-apt-keys
|
||||
- block:
|
||||
- name: Add galera 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: "{{ galera_gpg_keys }}"
|
||||
tags:
|
||||
- galera-apt-keys
|
||||
|
||||
- name: Add galera 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: "{{ galera_gpg_keys }}"
|
||||
when: add_keys|failed and (item.fallback_keyserver is defined or item.fallback_url is defined)
|
||||
tags:
|
||||
- galera-apt-keys
|
||||
rescue:
|
||||
- name: Add galera 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: "{{ galera_gpg_keys }}"
|
||||
when:
|
||||
- item.fallback_keyserver is defined or item.fallback_url is defined
|
||||
tags:
|
||||
- galera-apt-keys
|
||||
|
||||
- name: Add galera repo
|
||||
apt_repository:
|
||||
|
@ -26,31 +26,32 @@
|
||||
- { src: "/etc/mysql/conf.d", path: "/etc/my.cnf.d", state: "link", force: true }
|
||||
- { src: "/etc/mysql/my.cnf", path: "/etc/my.cnf", state: "link", force: true }
|
||||
|
||||
- name: Add galera gpg-keys
|
||||
rpm_key:
|
||||
state: present
|
||||
key: "{{ item.keyserver }}/{{ item.key_name }}"
|
||||
register: add_keys
|
||||
until: add_keys|success
|
||||
failed_when: false
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ galera_gpg_keys }}"
|
||||
tags:
|
||||
- galera-gpg-keys
|
||||
- block:
|
||||
- name: Add galera gpg-keys (primary keyserver)
|
||||
rpm_key:
|
||||
state: present
|
||||
key: "{{ item.keyserver }}/{{ item.key_name }}"
|
||||
register: add_keys
|
||||
until: add_keys|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ galera_gpg_keys }}"
|
||||
tags:
|
||||
- galera-gpg-keys
|
||||
|
||||
- name: Add galera gpg-keys using fallback keyserver
|
||||
rpm_key:
|
||||
state: present
|
||||
key: "{{ item.fallback_keyserver }}/{{ item.key_name }}"
|
||||
register: add_keys
|
||||
until: add_keys|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ galera_gpg_keys }}"
|
||||
when: add_keys|failed and (item.fallback_keyserver is defined)
|
||||
tags:
|
||||
- galera-gpg-keys
|
||||
rescue:
|
||||
- name: Add galera gpg-keys (fallback keyserver)
|
||||
rpm_key:
|
||||
state: present
|
||||
key: "{{ item.fallback_keyserver }}/{{ item.key_name }}"
|
||||
register: add_keys
|
||||
until: add_keys|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ galera_gpg_keys }}"
|
||||
when: item.fallback_keyserver is defined
|
||||
tags:
|
||||
- galera-gpg-keys
|
||||
|
||||
#TODO(cloudnull) Remove this task once we move to Ansible 2.1
|
||||
# where we can leverage the `yum_repository` module:
|
||||
|
Loading…
Reference in New Issue
Block a user