Merge "Optimize tasks for the container backend if defined"

This commit is contained in:
Zuul 2018-03-19 18:07:37 +00:00 committed by Gerrit Code Review
commit c7dcad5ada

View File

@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
- name: Set backingstore fact
set_fact:
container_backing_store: "{{ lxc_container_backing_store | default('None') }}"
- name: Create LXC cache dir - name: Create LXC cache dir
file: file:
path: "{{ cache_path_fact }}" path: "{{ cache_path_fact }}"
@ -23,17 +27,23 @@
file: file:
path: "{{ cache_path_fact }}/rootfs.tar.xz" path: "{{ cache_path_fact }}/rootfs.tar.xz"
state: "absent" state: "absent"
when:
- container_backing_store != 'machinectl'
# This is using a shell command because the ansible archive module does not # 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. # 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 # 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 - name: Create lxc image
shell: | shell: |
tar -Opc -C {{ lxc_image_cache_path }} . | {{ lxc_xz_bin }} -T 0 -{{ lxc_image_compression_ratio }} -c - > rootfs.tar.xz tar -Opc -C {{ lxc_image_cache_path }} . | {{ lxc_xz_bin }} -T 0 -{{ lxc_image_compression_ratio }} -c - > rootfs.tar.xz
args: args:
chdir: "{{ cache_path_fact }}/" chdir: "{{ cache_path_fact }}/"
warn: no warn: no
when:
- container_backing_store != 'machinectl'
tags: tags:
- skip_ansible_lint - skip_ansible_lint
@ -67,9 +77,11 @@
copy: copy:
content: "{{ cache_time }}" content: "{{ cache_time }}"
dest: "{{ cache_path_fact }}/build_id" dest: "{{ cache_path_fact }}/build_id"
when:
- container_backing_store != 'machinectl'
- include_tasks: "{{ item }}" - include_tasks: "{{ item }}"
with_first_found: with_first_found:
- files: - files:
- "lxc_container_{{ lxc_container_backing_store | default('None') }}.yml" - "lxc_container_{{ container_backing_store }}.yml"
skip: true skip: true