From 25c8e457b33c44698d7e00c87e685ec6fbb81bb1 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Evrard Date: Tue, 9 Feb 2016 12:46:50 +0100 Subject: [PATCH] Only update apt cache if necessary Workarounding the upstream ansible apt module bug documented here: https://github.com/ansible/ansible-modules-core/pull/1517 For the next versions of ansible we'll be using, we should check if the apt bug is fixed. When it's fixed, we could abandon this change and use the standard apt module with correct cache handling. Change-Id: I2aaf00da175f31d0157bbc4ae30a4e176b055078 --- playbooks/roles/ceph_client/defaults/main.yml | 3 +++ .../roles/ceph_client/tasks/ceph_install.yml | 19 ++++++++++++-- .../roles/haproxy_server/defaults/main.yml | 3 +++ .../tasks/haproxy_add_ppa_repo.yml | 26 ++++++++++++++----- .../haproxy_server/tasks/haproxy_install.yml | 18 ++++++++----- playbooks/roles/os_aodh/defaults/main.yml | 3 +++ .../roles/os_aodh/tasks/aodh_install.yml | 19 ++++++++++++-- .../roles/os_ceilometer/defaults/main.yml | 3 +++ .../tasks/ceilometer_install.yml | 19 ++++++++++++-- playbooks/roles/os_cinder/defaults/main.yml | 3 +++ .../roles/os_cinder/tasks/cinder_install.yml | 18 ++++++++----- playbooks/roles/os_glance/defaults/main.yml | 3 +++ .../roles/os_glance/tasks/glance_install.yml | 18 ++++++++----- playbooks/roles/os_heat/defaults/main.yml | 3 +++ .../roles/os_heat/tasks/heat_install.yml | 18 ++++++++----- playbooks/roles/os_horizon/defaults/main.yml | 3 +++ .../os_horizon/tasks/horizon_install.yml | 18 ++++++++----- playbooks/roles/os_keystone/defaults/main.yml | 3 +++ .../os_keystone/tasks/keystone_install.yml | 18 ++++++++----- playbooks/roles/os_neutron/defaults/main.yml | 3 +++ .../os_neutron/tasks/neutron_install.yml | 18 ++++++++----- playbooks/roles/os_nova/defaults/main.yml | 3 +++ .../tasks/nova_compute_kvm_install.yml | 19 +++++++++----- .../tasks/nova_console_novnc_install.yml | 18 ++++++++----- .../tasks/nova_console_spice_install.yml | 19 +++++++++----- .../roles/os_nova/tasks/nova_install.yml | 18 ++++++++----- playbooks/roles/os_swift/defaults/main.yml | 1 + .../roles/os_swift/tasks/swift_install.yml | 18 ++++++++----- 28 files changed, 251 insertions(+), 84 deletions(-) diff --git a/playbooks/roles/ceph_client/defaults/main.yml b/playbooks/roles/ceph_client/defaults/main.yml index 5d5b43efe2..09c5666c72 100644 --- a/playbooks/roles/ceph_client/defaults/main.yml +++ b/playbooks/roles/ceph_client/defaults/main.yml @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +## APT Cache Options +cache_timeout: 600 + # to user Ceph in OSA, you need to # - have the needed pools and a client user (for glance, cinder and/or nova) # pre-provisioned in your ceph cluster; OSA assumes to have root access to diff --git a/playbooks/roles/ceph_client/tasks/ceph_install.yml b/playbooks/roles/ceph_client/tasks/ceph_install.yml index 6e1c330611..4aaabd4159 100644 --- a/playbooks/roles/ceph_client/tasks/ceph_install.yml +++ b/playbooks/roles/ceph_client/tasks/ceph_install.yml @@ -13,12 +13,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +#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 + tags: + - ceph-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" + tags: + - ceph-apt-packages + - name: Install ceph packages apt: name: '{{ item.1 }}' state: latest - update_cache: yes - cache_valid_time: 600 register: install_packages until: install_packages|success retries: 5 diff --git a/playbooks/roles/haproxy_server/defaults/main.yml b/playbooks/roles/haproxy_server/defaults/main.yml index 6fa39f5614..e771157ef5 100644 --- a/playbooks/roles/haproxy_server/defaults/main.yml +++ b/playbooks/roles/haproxy_server/defaults/main.yml @@ -16,6 +16,9 @@ # Defines that the role will be deployed on a host machine is_metal: true +## APT Cache options +cache_timeout: 600 + haproxy_apt_repo_url: "http://ppa.launchpad.net/vbernat/haproxy-1.5/ubuntu" haproxy_apt_repo: repo: "deb {{ haproxy_apt_repo_url }} {{ ansible_distribution_release }} main" diff --git a/playbooks/roles/haproxy_server/tasks/haproxy_add_ppa_repo.yml b/playbooks/roles/haproxy_server/tasks/haproxy_add_ppa_repo.yml index 6e96dfdf6b..fab2efe1b1 100644 --- a/playbooks/roles/haproxy_server/tasks/haproxy_add_ppa_repo.yml +++ b/playbooks/roles/haproxy_server/tasks/haproxy_add_ppa_repo.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - haproxy-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - haproxy-apt-packages @@ -87,3 +93,11 @@ delay: 2 tags: - haproxy-repos + +- name: Update apt if necessary + apt: + update_cache: yes + when: add_repos|changed + tags: + - haproxy-repos + diff --git a/playbooks/roles/haproxy_server/tasks/haproxy_install.yml b/playbooks/roles/haproxy_server/tasks/haproxy_install.yml index 9e78269ce1..6ee6793a6b 100644 --- a/playbooks/roles/haproxy_server/tasks/haproxy_install.yml +++ b/playbooks/roles/haproxy_server/tasks/haproxy_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - haproxy-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - haproxy-apt-packages diff --git a/playbooks/roles/os_aodh/defaults/main.yml b/playbooks/roles/os_aodh/defaults/main.yml index 0b19da918f..1aa7bf26c8 100644 --- a/playbooks/roles/os_aodh/defaults/main.yml +++ b/playbooks/roles/os_aodh/defaults/main.yml @@ -17,6 +17,9 @@ debug: False verbose: False +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into aodh_venv_tag: untagged aodh_venv_bin: "/openstack/venvs/aodh-{{ aodh_venv_tag }}/bin" diff --git a/playbooks/roles/os_aodh/tasks/aodh_install.yml b/playbooks/roles/os_aodh/tasks/aodh_install.yml index f458cbe6f7..991299e9d5 100644 --- a/playbooks/roles/os_aodh/tasks/aodh_install.yml +++ b/playbooks/roles/os_aodh/tasks/aodh_install.yml @@ -13,12 +13,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +#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 + tags: + - aodh-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" + tags: + - aodh-apt-packages + - name: Install apt packages apt: pkg: "{{ item }}" state: latest - update_cache: yes - cache_valid_time: 600 register: install_packages until: install_packages|success retries: 5 diff --git a/playbooks/roles/os_ceilometer/defaults/main.yml b/playbooks/roles/os_ceilometer/defaults/main.yml index cc327bb8d6..20299ae6e3 100644 --- a/playbooks/roles/os_ceilometer/defaults/main.yml +++ b/playbooks/roles/os_ceilometer/defaults/main.yml @@ -17,6 +17,9 @@ debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into ceilometer_venv_tag: untagged ceilometer_venv_bin: "/openstack/venvs/ceilometer-{{ ceilometer_venv_tag }}/bin" diff --git a/playbooks/roles/os_ceilometer/tasks/ceilometer_install.yml b/playbooks/roles/os_ceilometer/tasks/ceilometer_install.yml index 02abeaf77c..e8b39de0ba 100644 --- a/playbooks/roles/os_ceilometer/tasks/ceilometer_install.yml +++ b/playbooks/roles/os_ceilometer/tasks/ceilometer_install.yml @@ -13,12 +13,27 @@ # See the License for the specific language governing permissions and # limitations under the License. +#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 + tags: + - ceilometer-apt-packages + +- name: Update apt if needed + apt: + update_cache: yes + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" + tags: + - ceilometer-apt-packages + - name: Install apt packages apt: pkg: "{{ item }}" state: latest - update_cache: yes - cache_valid_time: 600 register: install_packages until: install_packages|success retries: 5 diff --git a/playbooks/roles/os_cinder/defaults/main.yml b/playbooks/roles/os_cinder/defaults/main.yml index e6da8560c8..42c180b484 100644 --- a/playbooks/roles/os_cinder/defaults/main.yml +++ b/playbooks/roles/os_cinder/defaults/main.yml @@ -16,6 +16,9 @@ # Defines that the role will be deployed on a host machine is_metal: true +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into cinder_venv_tag: untagged cinder_venv_bin: "/openstack/venvs/cinder-{{ cinder_venv_tag }}/bin" diff --git a/playbooks/roles/os_cinder/tasks/cinder_install.yml b/playbooks/roles/os_cinder/tasks/cinder_install.yml index 2b33bc5f65..44031213b6 100644 --- a/playbooks/roles/os_cinder/tasks/cinder_install.yml +++ b/playbooks/roles/os_cinder/tasks/cinder_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - cinder-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - cinder-apt-packages diff --git a/playbooks/roles/os_glance/defaults/main.yml b/playbooks/roles/os_glance/defaults/main.yml index 3d36aa77e2..bba2fd730c 100644 --- a/playbooks/roles/os_glance/defaults/main.yml +++ b/playbooks/roles/os_glance/defaults/main.yml @@ -17,6 +17,9 @@ debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into glance_venv_tag: untagged glance_venv_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin" diff --git a/playbooks/roles/os_glance/tasks/glance_install.yml b/playbooks/roles/os_glance/tasks/glance_install.yml index 1ea60f9ce4..aadd38be02 100644 --- a/playbooks/roles/os_glance/tasks/glance_install.yml +++ b/playbooks/roles/os_glance/tasks/glance_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - glance-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - glance-apt-packages diff --git a/playbooks/roles/os_heat/defaults/main.yml b/playbooks/roles/os_heat/defaults/main.yml index e8c5875c61..823751361d 100644 --- a/playbooks/roles/os_heat/defaults/main.yml +++ b/playbooks/roles/os_heat/defaults/main.yml @@ -23,6 +23,9 @@ heat_ceilometer_enabled: False debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into heat_venv_tag: untagged heat_venv_bin: "/openstack/venvs/heat-{{ heat_venv_tag }}/bin" diff --git a/playbooks/roles/os_heat/tasks/heat_install.yml b/playbooks/roles/os_heat/tasks/heat_install.yml index 46c088b801..213d7c74af 100644 --- a/playbooks/roles/os_heat/tasks/heat_install.yml +++ b/playbooks/roles/os_heat/tasks/heat_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - heat-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - heat-apt-packages diff --git a/playbooks/roles/os_horizon/defaults/main.yml b/playbooks/roles/os_horizon/defaults/main.yml index b61ca1d915..23703010b8 100644 --- a/playbooks/roles/os_horizon/defaults/main.yml +++ b/playbooks/roles/os_horizon/defaults/main.yml @@ -17,6 +17,9 @@ debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into horizon_venv_tag: untagged horizon_venv_bin: "/openstack/venvs/horizon-{{ horizon_venv_tag }}/bin" diff --git a/playbooks/roles/os_horizon/tasks/horizon_install.yml b/playbooks/roles/os_horizon/tasks/horizon_install.yml index 11446a6ebc..3d44b6e659 100644 --- a/playbooks/roles/os_horizon/tasks/horizon_install.yml +++ b/playbooks/roles/os_horizon/tasks/horizon_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - horizon-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - horizon-apt-packages diff --git a/playbooks/roles/os_keystone/defaults/main.yml b/playbooks/roles/os_keystone/defaults/main.yml index 82dcb50063..b5d7f792a3 100644 --- a/playbooks/roles/os_keystone/defaults/main.yml +++ b/playbooks/roles/os_keystone/defaults/main.yml @@ -17,6 +17,9 @@ debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into keystone_venv_tag: untagged keystone_venv_bin: "/openstack/venvs/keystone-{{ keystone_venv_tag }}/bin" diff --git a/playbooks/roles/os_keystone/tasks/keystone_install.yml b/playbooks/roles/os_keystone/tasks/keystone_install.yml index c81e9da062..5aeac5f3cc 100644 --- a/playbooks/roles/os_keystone/tasks/keystone_install.yml +++ b/playbooks/roles/os_keystone/tasks/keystone_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - keystone-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - keystone-apt-packages diff --git a/playbooks/roles/os_neutron/defaults/main.yml b/playbooks/roles/os_neutron/defaults/main.yml index 1848195bbd..7f09dc99a8 100644 --- a/playbooks/roles/os_neutron/defaults/main.yml +++ b/playbooks/roles/os_neutron/defaults/main.yml @@ -20,6 +20,9 @@ is_metal: true debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into neutron_venv_tag: untagged neutron_venv_bin: "/openstack/venvs/neutron-{{ neutron_venv_tag }}/bin" diff --git a/playbooks/roles/os_neutron/tasks/neutron_install.yml b/playbooks/roles/os_neutron/tasks/neutron_install.yml index f24930a615..5a34b7091d 100644 --- a/playbooks/roles/os_neutron/tasks/neutron_install.yml +++ b/playbooks/roles/os_neutron/tasks/neutron_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - neutron-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - neutron-apt-packages diff --git a/playbooks/roles/os_nova/defaults/main.yml b/playbooks/roles/os_nova/defaults/main.yml index efcf32d3dc..1e1c609c8e 100644 --- a/playbooks/roles/os_nova/defaults/main.yml +++ b/playbooks/roles/os_nova/defaults/main.yml @@ -20,6 +20,9 @@ nova_ceilometer_enabled: False debug: False verbose: True +## APT Cache options +cache_timeout: 600 + # Name of the virtual env to deploy into nova_venv_tag: untagged nova_venv_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" diff --git a/playbooks/roles/os_nova/tasks/nova_compute_kvm_install.yml b/playbooks/roles/os_nova/tasks/nova_compute_kvm_install.yml index 40b6231d56..90ffcea543 100644 --- a/playbooks/roles/os_nova/tasks/nova_compute_kvm_install.yml +++ b/playbooks/roles/os_nova/tasks/nova_compute_kvm_install.yml @@ -13,14 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - nova-apt-packages + - nova-compute-kvm-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - nova-apt-packages - nova-compute-kvm-apt-packages diff --git a/playbooks/roles/os_nova/tasks/nova_console_novnc_install.yml b/playbooks/roles/os_nova/tasks/nova_console_novnc_install.yml index 8ef6819c0f..08273eb5d4 100644 --- a/playbooks/roles/os_nova/tasks/nova_console_novnc_install.yml +++ b/playbooks/roles/os_nova/tasks/nova_console_novnc_install.yml @@ -29,14 +29,20 @@ - nova-install - nova-novnc-git -- name: Update apt sources +#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 + tags: + - nova-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - nova-apt-packages - nova-novnc-apt-packages diff --git a/playbooks/roles/os_nova/tasks/nova_console_spice_install.yml b/playbooks/roles/os_nova/tasks/nova_console_spice_install.yml index 5086bf47be..353cde8135 100644 --- a/playbooks/roles/os_nova/tasks/nova_console_spice_install.yml +++ b/playbooks/roles/os_nova/tasks/nova_console_spice_install.yml @@ -13,14 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - nova-apt-packages + - nova-spice-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - nova-apt-packages - nova-spice-apt-packages diff --git a/playbooks/roles/os_nova/tasks/nova_install.yml b/playbooks/roles/os_nova/tasks/nova_install.yml index 58b6204ebc..7bea71a9ef 100644 --- a/playbooks/roles/os_nova/tasks/nova_install.yml +++ b/playbooks/roles/os_nova/tasks/nova_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - nova-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - nova-apt-packages diff --git a/playbooks/roles/os_swift/defaults/main.yml b/playbooks/roles/os_swift/defaults/main.yml index 8e705ec0cf..e10b21a55e 100644 --- a/playbooks/roles/os_swift/defaults/main.yml +++ b/playbooks/roles/os_swift/defaults/main.yml @@ -19,6 +19,7 @@ swift_ceilometer_enabled: False ## Verbosity Options debug: False verbose: True +cache_timeout: 600 # Name of the virtual env to deploy into swift_venv_tag: untagged diff --git a/playbooks/roles/os_swift/tasks/swift_install.yml b/playbooks/roles/os_swift/tasks/swift_install.yml index e7c2694f82..efded02f20 100644 --- a/playbooks/roles/os_swift/tasks/swift_install.yml +++ b/playbooks/roles/os_swift/tasks/swift_install.yml @@ -13,14 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Update apt sources +#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 + tags: + - swift-apt-packages + +- name: Update apt if needed apt: update_cache: yes - cache_valid_time: 600 - register: apt_update - until: apt_update|success - retries: 5 - delay: 2 + when: "ansible_date_time.epoch|float - apt_cache_stat.stat.mtime > {{cache_timeout}}" tags: - swift-apt-packages