Use local container meta-data

The current lxc meta-data process is one where we download an archive
from the upstream lxc images and store it locally on the host. While the
archive is small, this is a process that can break due to transient
networking issues and is an external dependency that we don't need.

The meta-data for the containers we build is all the same between
distros so it's easy to replicate and maintain as a local dependency.
This change creates a templates meta-data folder and stores our
required meta-data items within it. With this change we'll ensure
all containers are built with the same capabilities without requiring
access to an upstream repo and will improve the general speed of
deployment due to the task simplification and removal of an external
dependency.

Change-Id: I999d7068ce05645c477408fbd40556427c202a40
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2018-03-18 02:12:23 -05:00 committed by Kevin Carter (cloudnull)
parent ba01eb1875
commit 44409262d2
7 changed files with 23 additions and 28 deletions

View File

@ -80,11 +80,6 @@
path: "/tmp/rootfs.tar.xz"
state: "absent"
- name: Remove metadata archive
file:
path: "/tmp/meta.tar.xz"
state: "absent"
- name: Restart dnsmasq
service:
name: "lxc-dnsmasq"

View File

@ -37,29 +37,19 @@
tags:
- skip_ansible_lint
- name: Fetch LXC image-metadata
shell: >
aria2c
--max-connection-per-server=4
--continue
--allow-overwrite=true
--dir=/tmp
--out=meta.tar.xz
--check-certificate={{ (lxc_hosts_validate_certs | bool) | lower }}
{% for server in lxc_image_cache_server_mirrors %}{{ server }}/{{ lxc_images[0].split(';')[-1] }}/meta.tar.xz {% endfor %}
args:
warn: no
tags:
- skip_ansible_lint
- always
- name: Place container metadata
unarchive:
src: "/tmp/meta.tar.xz"
dest: "{{ cache_path_fact }}"
remote_src: True
notify:
- Remove metadata archive
- name: Drop container meta-data
template:
src: "meta-data/{{ item }}"
dest: "{{ cache_path_fact }}/{{ item }}"
owner: "root"
group: "root"
mode: "0644"
with_items:
- config
- config.5
- create-message
- expiry
- templates
- name: Set cache expiry
shell: "date -d @{{ (cache_time | int) + 31536000 }}"

View File

@ -0,0 +1,2 @@
lxc.include = LXC_TEMPLATE_CONFIG/{{ lxc_cache_map.distro }}.common.conf
lxc.arch = x86_64

View File

@ -0,0 +1,2 @@
lxc.include = LXC_TEMPLATE_CONFIG/common.conf
lxc.arch = x86_64

View File

@ -0,0 +1,4 @@
Created a {{ lxc_cache_map.distro }} container (release={{ lxc_cache_map.release }}, arch={{ lxc_cache_map.arch }}, variant={{ lxc_cache_default_variant }})
Use lxc-attach or chroot directly into the rootfs to set a root password
or create user accounts.

View File

View File

@ -0,0 +1,2 @@
/etc/hostname
/etc/hosts