From c1520f1b37c5ded86a37a8f1f4e5d883f1f43d01 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Sun, 18 Mar 2018 02:04:15 -0500 Subject: [PATCH] Optimize tasks for the container backend if defined When the machinectl backend is in service there's no need to create a tarball of the container rootfs. This change sets a fact for the backend store and skips tasks that are unnecessary when using machinectl. Change-Id: Ie759ae486157a31523b261041eb66bbb20f80e5a Signed-off-by: Kevin Carter --- tasks/lxc_cache_create.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tasks/lxc_cache_create.yml b/tasks/lxc_cache_create.yml index 5c9289d7..03a5c419 100644 --- a/tasks/lxc_cache_create.yml +++ b/tasks/lxc_cache_create.yml @@ -13,6 +13,10 @@ # See the License for the specific language governing permissions and # limitations under the License. +- name: Set backingstore fact + set_fact: + container_backing_store: "{{ lxc_container_backing_store | default('None') }}" + - name: Create LXC cache dir file: path: "{{ cache_path_fact }}" @@ -23,17 +27,23 @@ file: path: "{{ cache_path_fact }}/rootfs.tar.xz" state: "absent" + when: + - container_backing_store != 'machinectl' # This is using a shell command because the ansible archive module does not # provide for the options needed to properly create an LXC image archive. # Ansible will print a warning since this task calls 'tar' directly and we -# suppress this warning with 'warn: no'. +# suppress this warning with 'warn: no'. This task is not run when the backend +# is set to "machinectl" because the "machinectl" backend directly clones the +# base image instead of unpacking a container tarball. - name: Create lxc image shell: | tar -Opc -C {{ lxc_image_cache_path }} . | {{ lxc_xz_bin }} -T 0 -{{ lxc_image_compression_ratio }} -c - > rootfs.tar.xz args: chdir: "{{ cache_path_fact }}/" warn: no + when: + - container_backing_store != 'machinectl' tags: - skip_ansible_lint @@ -79,10 +89,12 @@ copy: content: "{{ cache_time }}" dest: "{{ cache_path_fact }}/build_id" + when: + - container_backing_store != 'machinectl' - include: "{{ item }}" static: no with_first_found: - files: - - "lxc_container_{{ lxc_container_backing_store | default('None') }}.yml" + - "lxc_container_{{ container_backing_store }}.yml" skip: true