Ensure that apt cache is up to date before installing packages

Change-Id: I6db566bc0a1e3a9d2ad423389522f1c1c418d07c
This commit is contained in:
Jesse Pretorius 2016-08-15 12:38:33 +01:00
parent 4b02a8cb3a
commit ae00b93ebc
2 changed files with 20 additions and 0 deletions

View File

@ -41,6 +41,9 @@ pip_required_pip_packages:
- ndg-httpsclient # SSL SNI support
- requests # SSL SNI support
## APT Cache options
cache_timeout: 600
# Validate Certificates when downloading pip. May be set to "no" when proxy server
# is intercepting the certificates.
pip_validate_certs: "yes"

View File

@ -25,6 +25,23 @@
when:
- ansible_pkg_mgr == 'yum'
#TODO(evrardjp): Replace the next 2 tasks by a standard apt with cache
#when https://github.com/ansible/ansible-modules-core/pull/1517 is merged
#in 1.9.x or we move to 2.0 (if tested working)
- name: Check apt last update file
stat:
path: /var/cache/apt
register: apt_cache_stat
when:
- ansible_pkg_mgr == 'apt'
- name: Update apt if needed
apt:
update_cache: yes
when:
- ansible_pkg_mgr == 'apt'
- "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}"
- name: Install apt packages
apt:
pkg: "{{ item }}"