From 2449ccb64076cf2b273ed0c3116c43be58b8c61e Mon Sep 17 00:00:00 2001 From: Serge van Ginderachter Date: Sat, 23 May 2015 13:31:56 +0200 Subject: [PATCH] Avoid keeping re-downloading container caches When the cache tarball gets deleted at the end the task set in playbooks/roles/lxc_hosts/tasks/lxc_cache.yml then it will be downloaded again at subsequent runs, which makes the download task not idempotent, and needlessly slow. The unarchive task also needs to only be executed if the download task performed a change. Ensure that the location the download is placed and the directory it's extracted to are different. Change-Id: I4e433e82499f5cfa0b5dde44a6aa7bab113d9e0e --- playbooks/roles/lxc_hosts/tasks/lxc_cache.yml | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/playbooks/roles/lxc_hosts/tasks/lxc_cache.yml b/playbooks/roles/lxc_hosts/tasks/lxc_cache.yml index 798400446a..164d1ce6de 100644 --- a/playbooks/roles/lxc_hosts/tasks/lxc_cache.yml +++ b/playbooks/roles/lxc_hosts/tasks/lxc_cache.yml @@ -16,8 +16,9 @@ - name: Download lxc cache(s) get_url: url: "{{ item.url }}" - dest: "/var/cache/lxc/{{ item.name }}" + dest: "/var/cache/lxc_{{ item.name }}" mode: "0644" + force: no register: cache_download until: cache_download|success with_items: lxc_container_caches @@ -27,19 +28,12 @@ - name: Move lxc cached image into place unarchive: - src: "/var/cache/lxc/{{ item.name }}" + src: "/var/cache/lxc_{{ item.name }}" dest: "/var/cache/lxc/" copy: "no" with_items: lxc_container_caches + when: cache_download|changed tags: - lxc-cache - lxc-cache-unarchive -- name: Remove cache tarball - file: - path: "/var/cache/lxc/{{ item.name }}" - state: absent - with_items: lxc_container_caches - tags: - - lxc-cache - - lxc-cache-remove