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
This commit is contained in:
parent
a2a4bb6e3b
commit
2449ccb640
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user