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: I43bd89e9bd5e2094eb0c138e17045ea64cd62c4d
Partial-Bug: #1750656
(cherry picked from commit db70936846)
This commit is contained in:
Jesse Pretorius 2018-02-22 14:23:47 +00:00 committed by Jesse Pretorius (odyssey4me)
parent de60aa5d96
commit 6dd85991b2
1 changed files with 15 additions and 2 deletions

View File

@ -63,13 +63,26 @@
when:
- ceph_pkg_source == 'uca'
# 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 ceph repo(s)
apt_repository:
repo: "{{ ceph_apt_repos[ceph_pkg_source].repo }}"
state: "{{ ceph_apt_repos[ceph_pkg_source].state }}"
filename: "{{ ceph_apt_repos[ceph_pkg_source].filename | default(omit) }}"
update_cache: yes
update_cache: no
register: add_repos
until: add_repos|success
- name: Update Apt cache
apt:
update_cache: yes
when: add_repos | changed
register: update_apt_cache
until: update_apt_cache | success
retries: 5
delay: 2