From 4f7a87eba7afc290417ffe2f824d32fe30374c58 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Fri, 4 Nov 2016 16:51:34 +0000 Subject: [PATCH] Use apt_repository update_cache feature With ansible 2.2, apt_repository update_cache feature has been fixed. When a new repo will be added, apt-get update will be run after the addition if update_cache is set to yes. This combined with the apt module now properly checking the cache validity, we can now have proper updating of the cache with registering variables. Change-Id: I70a9892f11c754aba44a7a6e0d99cec515ba3e33 --- tasks/nova_compute_powervm_install.yml | 11 +---------- tasks/nova_install_apt.yml | 10 +++------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/tasks/nova_compute_powervm_install.yml b/tasks/nova_compute_powervm_install.yml index b95b55fa..29d538cd 100644 --- a/tasks/nova_compute_powervm_install.yml +++ b/tasks/nova_compute_powervm_install.yml @@ -29,6 +29,7 @@ apt_repository: repo: "{{ novalink_repo.repo }}" state: "{{ novalink_repo.state }}" + update_cache: yes register: add_nv_repos until: add_nv_repos|success retries: 5 @@ -36,16 +37,6 @@ tags: - novalink-repo -- name: Update apt if needed - apt: - update_cache: yes - when: add_nv_repos|changed - tags: - - nova-apt-packages - - nova-compute-powervm-apt-packages - # do not trigger ANSIBLE0016 - - skip_ansible_lint - - name: Install apt packages apt: pkg: "{{ item }}" diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml index 8ae7b88c..e3fc6f7b 100644 --- a/tasks/nova_install_apt.yml +++ b/tasks/nova_install_apt.yml @@ -17,6 +17,8 @@ apt: pkg: ubuntu-cloud-keyring state: "{{ nova_package_state }}" + update_cache: yes + cache_valid_time: "{{ cache_timeout }}" when: nova_uca_enable register: nova_uca_add_keys tags: @@ -26,6 +28,7 @@ apt_repository: repo: "{{ uca_repo }}" state: present + update_cache: yes register: nova_uca_add_repo when: nova_uca_enable until: add_repo|success @@ -34,13 +37,6 @@ tags: - add-uca-repo -- name: Update apt if needed - apt: - update_cache: yes - when: nova_uca_add_keys | changed or nova_uca_add_repo | changed - tags: - - nova-apt-packages - - name: Install apt packages (common) apt: pkg: "{{ item }}"