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 <kevin.carter@rackspace.com>
This commit is contained in:
parent
4b76998744
commit
c1520f1b37
@ -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
|
||||||
|
|
||||||
@ -79,10 +89,12 @@
|
|||||||
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: "{{ item }}"
|
- include: "{{ item }}"
|
||||||
static: no
|
static: no
|
||||||
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
|
||||||
|
Loading…
Reference in New Issue
Block a user