Fix cache update after initial apt_repository fail
If apt_repository fails to update the apt cache after updating the configuration, retries don't register there was a change and so no attempt is made to update the cache by the module on the second attempt. This failure can result in a failure to install packages. This change adds an apt module task to update the cache if the apt_repository task registers a change. This means updating the cache will get retried on failure and no longer fail silently. Change-Id: Id059dbec3466cb1ef3ea567249f52384a8ade515 Partial-Bug: #1750656
This commit is contained in:
parent
22f663a9c3
commit
23bd341129
|
@ -46,29 +46,37 @@
|
||||||
tags:
|
tags:
|
||||||
- rabbitmq-apt-keys
|
- rabbitmq-apt-keys
|
||||||
|
|
||||||
|
# When updating the cache in the apt_repository
|
||||||
|
# task, and the update fails, a retry does not
|
||||||
|
# detect a change the second attempt and therefore
|
||||||
|
# does not update the cache, resulting in a changed
|
||||||
|
# repo config, but no updated cache. To work around
|
||||||
|
# this bug we implement the change of repo config
|
||||||
|
# and the cache update as two seperate tasks.
|
||||||
- name: Add rabbitmq repo
|
- name: Add rabbitmq repo
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: "{{ rabbitmq_repo.repo }}"
|
repo: "{{ rabbitmq_repo.repo }}"
|
||||||
state: "{{ rabbitmq_repo.state }}"
|
state: "{{ rabbitmq_repo.state }}"
|
||||||
filename: "{{ rabbitmq_repo.filename | default(omit) }}"
|
filename: "{{ rabbitmq_repo.filename | default(omit) }}"
|
||||||
register: add_repos
|
register: add_rabbitmq_repos
|
||||||
until: add_repos|success
|
|
||||||
retries: 5
|
|
||||||
delay: 2
|
|
||||||
when:
|
when:
|
||||||
- rabbitmq_install_method == 'external_repo'
|
- rabbitmq_install_method == 'external_repo'
|
||||||
tags:
|
tags:
|
||||||
- rabbitmq-repos
|
- rabbitmq-repos
|
||||||
|
|
||||||
|
# When updating the cache in the apt_repository
|
||||||
|
# task, and the update fails, a retry does not
|
||||||
|
# detect a change the second attempt and therefore
|
||||||
|
# does not update the cache, resulting in a changed
|
||||||
|
# repo config, but no updated cache. To work around
|
||||||
|
# this bug we implement the change of repo config
|
||||||
|
# and the cache update as two seperate tasks.
|
||||||
- name: Add erlang repo
|
- name: Add erlang repo
|
||||||
apt_repository:
|
apt_repository:
|
||||||
repo: "{{ rabbitmq_erlang_repo.repo }}"
|
repo: "{{ rabbitmq_erlang_repo.repo }}"
|
||||||
state: "{{ rabbitmq_erlang_repo.state }}"
|
state: "{{ rabbitmq_erlang_repo.state }}"
|
||||||
filename: "{{ rabbitmq_erlang_repo.filename | default(omit) }}"
|
filename: "{{ rabbitmq_erlang_repo.filename | default(omit) }}"
|
||||||
register: add_repos
|
register: add_erlang_repos
|
||||||
until: add_repos|success
|
|
||||||
retries: 5
|
|
||||||
delay: 2
|
|
||||||
tags:
|
tags:
|
||||||
- rabbitmq-repos
|
- rabbitmq-repos
|
||||||
|
|
||||||
|
@ -77,7 +85,7 @@
|
||||||
pkg: "{{ rabbitmq_dependencies | deprecated(rabbitmq_apt_packages, 'rabbitmq_apt_packages', 'rabbitmq_dependencies', 'Ocata') }}"
|
pkg: "{{ rabbitmq_dependencies | deprecated(rabbitmq_apt_packages, 'rabbitmq_apt_packages', 'rabbitmq_dependencies', 'Ocata') }}"
|
||||||
state: "{{ rabbitmq_package_state }}"
|
state: "{{ rabbitmq_package_state }}"
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
cache_valid_time: "{{ cache_timeout }}"
|
cache_valid_time: "{{ (add_rabbitmq_repos | changed or add_erlang_repos | changed) | ternary('0', cache_timeout) }}"
|
||||||
register: install_packages
|
register: install_packages
|
||||||
until: install_packages | success
|
until: install_packages | success
|
||||||
retries: 5
|
retries: 5
|
||||||
|
|
Loading…
Reference in New Issue