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 puts responsibility for updating the cache on the apt module
task, this means updating the cache will get retried on failure and no
longer fail silently.

The changes made include:
- the two apt_repository tasks have their update_cache parameter set to
  no so it is clear where any update happens and there is no unnecessary
  duplication of cache updates.
- the use of retries is removed given the tasks no longer need to make
  use of the network.
- the apt_repository task result variables have been given unique names
  to ensure that the cache is updated if only the galera repository is
  added.

Change-Id: I91b7929113f720bc3c55343c481096657376302f
Partial-bug: 1750656
(cherry picked from commit 7596eaa889)
This commit is contained in:
git-harry 2018-02-20 20:57:00 +00:00
parent 67628375be
commit daf9d5dc03
1 changed files with 9 additions and 9 deletions

View File

@ -64,10 +64,8 @@
repo: "{{ galera_repo.repo }}"
filename: "{{ galera_repo.filename | default(omit) }}"
state: "{{ galera_repo.state }}"
register: add_repos
until: add_repos|success
retries: 5
delay: 2
update_cache: "no"
register: add_galera_repo
tags:
- galera-repos
@ -76,10 +74,8 @@
repo: "{{ galera_percona_xtrabackup_repo.repo }}"
filename: "{{ galera_percona_xtrabackup_repo.filename | default(omit) }}"
state: "{{ (use_percona_upstream | bool) | ternary('present','absent') }}"
register: add_repos
until: add_repos|success
retries: 5
delay: 2
update_cache: "no"
register: add_percona_repo
tags:
- percona-repos
@ -105,7 +101,11 @@
name: "{{ galera_install_packages_list | selectattr('enabled') | rejectattr('local_pkg') | sum(attribute='packages', start=[]) }}"
state: "{{ galera_server_package_state }}"
update_cache: yes
cache_valid_time: "{{ (add_repos | changed) | ternary('0', cache_timeout) }}"
cache_valid_time: "{{ (add_galera_repo | changed or add_percona_repo | changed) | ternary('0', cache_timeout) }}"
register: install_remote_apt_packages
until: install_remote_apt_packages|success
retries: 5
delay: 2
- name: Install galera_server role local packages (apt)
apt: