79eb16e44d
To greatly reduce the amount of log noise from skipped tasks, when setting the 'lxc_images' var filter it to only include items that begin with the 'cache_index_item' var. The when clauses in tasks that looped through 'lxc_images' looking for this same match can be removed. Change-Id: I4bf7b32faa9ed0a8cddeb0792f912c0100dbece8
93 lines
2.8 KiB
YAML
93 lines
2.8 KiB
YAML
---
|
|
# Copyright 2016, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Create LXC cache dir
|
|
file:
|
|
path: "{{ cache_path_fact }}"
|
|
state: "directory"
|
|
recurse: true
|
|
|
|
- name: Remove existing cache archive
|
|
file:
|
|
path: "{{ cache_path_fact }}/rootfs.tar.xz"
|
|
state: "absent"
|
|
|
|
# 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.
|
|
- name: Create lxc image
|
|
shell: |
|
|
tar -Opc -C {{ lxc_image_cache_path }} . | {{ lxc_xz_bin }} -{{ lxc_image_compression_ratio }} -c - > rootfs.tar.xz
|
|
args:
|
|
chdir: "{{ cache_path_fact }}/"
|
|
notify: Destroy base container
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Update LXC image meta data
|
|
get_url:
|
|
url: "{{ lxc_image_cache_server }}/{{ item.split(';')[-1] }}/meta.tar.xz"
|
|
dest: "/tmp/meta.tar.xz"
|
|
with_items: "{{ lxc_images }}"
|
|
|
|
- name: Place container metadata
|
|
unarchive:
|
|
src: "/tmp/meta.tar.xz"
|
|
dest: "{{ cache_path_fact }}"
|
|
remote_src: True
|
|
|
|
- name: Set cache expiry
|
|
shell: "date -d @{{ (cache_time | int) + 31536000 }} > {{ cache_path_fact }}/expiry"
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Set build ID
|
|
shell: "echo {{ cache_time }} > {{ cache_path_fact }}/build_id"
|
|
tags:
|
|
- skip_ansible_lint
|
|
|
|
- name: Create base container to use for overlayfs containers
|
|
lxc_container:
|
|
name: "{{ lxc_container_base_name }}"
|
|
template: "download"
|
|
state: stopped
|
|
backing_store: "dir"
|
|
template_options: "{{ lxc_cache_download_template_options }}"
|
|
register: cache_download
|
|
retries: 3
|
|
delay: 10
|
|
until: cache_download|success
|
|
environment: "{{ lxc_cache_environment }}"
|
|
when:
|
|
- lxc_container_backing_store is defined
|
|
- lxc_container_backing_store == 'overlayfs'
|
|
|
|
- name: Create base container to use for LVM-backed copy-on-write containers
|
|
lxc_container:
|
|
name: "{{ lxc_container_base_name }}"
|
|
template: "download"
|
|
state: stopped
|
|
backing_store: "lvm"
|
|
template_options: "{{ lxc_cache_download_template_options }}"
|
|
register: cache_download
|
|
retries: 3
|
|
delay: 10
|
|
until: cache_download|success
|
|
environment: "{{ lxc_cache_environment }}"
|
|
when:
|
|
- lxc_container_backing_store is defined
|
|
- lxc_container_backing_store == 'lvm'
|
|
- lxc_container_backing_method is defined
|
|
- lxc_container_backing_method == 'copy-on-write'
|