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:
Jesse Pretorius 2018-02-22 14:48:19 +00:00
parent 22f663a9c3
commit 23bd341129
1 changed files with 18 additions and 10 deletions

View File

@ -46,29 +46,37 @@
tags:
- 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
apt_repository:
repo: "{{ rabbitmq_repo.repo }}"
state: "{{ rabbitmq_repo.state }}"
filename: "{{ rabbitmq_repo.filename | default(omit) }}"
register: add_repos
until: add_repos|success
retries: 5
delay: 2
register: add_rabbitmq_repos
when:
- rabbitmq_install_method == 'external_repo'
tags:
- 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
apt_repository:
repo: "{{ rabbitmq_erlang_repo.repo }}"
state: "{{ rabbitmq_erlang_repo.state }}"
filename: "{{ rabbitmq_erlang_repo.filename | default(omit) }}"
register: add_repos
until: add_repos|success
retries: 5
delay: 2
register: add_erlang_repos
tags:
- rabbitmq-repos
@ -77,9 +85,9 @@
pkg: "{{ rabbitmq_dependencies | deprecated(rabbitmq_apt_packages, 'rabbitmq_apt_packages', 'rabbitmq_dependencies', 'Ocata') }}"
state: "{{ rabbitmq_package_state }}"
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
until: install_packages|success
until: install_packages | success
retries: 5
delay: 2
tags: