From 44409262d21e3b4f29c88232434205051f4ce89c Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Sun, 18 Mar 2018 02:12:23 -0500 Subject: [PATCH] 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 --- handlers/main.yml | 5 ----- tasks/lxc_cache_create.yml | 36 +++++++++++------------------- templates/meta-data/config | 2 ++ templates/meta-data/config.5 | 2 ++ templates/meta-data/create-message | 4 ++++ templates/meta-data/expiry | 0 templates/meta-data/templates | 2 ++ 7 files changed, 23 insertions(+), 28 deletions(-) create mode 100644 templates/meta-data/config create mode 100644 templates/meta-data/config.5 create mode 100644 templates/meta-data/create-message create mode 100644 templates/meta-data/expiry create mode 100644 templates/meta-data/templates diff --git a/handlers/main.yml b/handlers/main.yml index 018bb275..2da9e103 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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" diff --git a/tasks/lxc_cache_create.yml b/tasks/lxc_cache_create.yml index 1e6c76ba..e5842743 100644 --- a/tasks/lxc_cache_create.yml +++ b/tasks/lxc_cache_create.yml @@ -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 }}" diff --git a/templates/meta-data/config b/templates/meta-data/config new file mode 100644 index 00000000..aa8f1f4d --- /dev/null +++ b/templates/meta-data/config @@ -0,0 +1,2 @@ +lxc.include = LXC_TEMPLATE_CONFIG/{{ lxc_cache_map.distro }}.common.conf +lxc.arch = x86_64 diff --git a/templates/meta-data/config.5 b/templates/meta-data/config.5 new file mode 100644 index 00000000..7573ff31 --- /dev/null +++ b/templates/meta-data/config.5 @@ -0,0 +1,2 @@ +lxc.include = LXC_TEMPLATE_CONFIG/common.conf +lxc.arch = x86_64 diff --git a/templates/meta-data/create-message b/templates/meta-data/create-message new file mode 100644 index 00000000..85d21eec --- /dev/null +++ b/templates/meta-data/create-message @@ -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. diff --git a/templates/meta-data/expiry b/templates/meta-data/expiry new file mode 100644 index 00000000..e69de29b diff --git a/templates/meta-data/templates b/templates/meta-data/templates new file mode 100644 index 00000000..15e81481 --- /dev/null +++ b/templates/meta-data/templates @@ -0,0 +1,2 @@ +/etc/hostname +/etc/hosts