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
This commit is contained in:
Jean-Philippe Evrard 2016-11-04 16:51:34 +00:00 committed by Jesse Pretorius (odyssey4me)
parent 59ea9b151a
commit 4f7a87eba7
2 changed files with 4 additions and 17 deletions

View File

@ -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 }}"

View File

@ -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 }}"