From daf9d5dc03e732a85476a5c2555ee0570c1acbac Mon Sep 17 00:00:00 2001 From: git-harry Date: Tue, 20 Feb 2018 20:57:00 +0000 Subject: [PATCH] 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 7596eaa8898e774e4779417ac8c1fec38f634977) --- tasks/galera_install_apt.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tasks/galera_install_apt.yml b/tasks/galera_install_apt.yml index 4d65da77..cf92d112 100644 --- a/tasks/galera_install_apt.yml +++ b/tasks/galera_install_apt.yml @@ -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: