Implement base container for overlayfs-backed containers

Since overlayfs is now part of the mainstream kernel, it makes sense
to take advantage of it to speed up the container creation process.

This patch implements a base container to be used in the container
creation process if 'overlayfs' is set as the container backing
store.

Change-Id: I20123b83af10c0890f4d5945b9fb230acd664213
This commit is contained in:
Jesse Pretorius 2016-06-13 15:31:53 +01:00 committed by Jesse Pretorius (odyssey4me)
parent ef6f746bed
commit a4b52f0a49
3 changed files with 31 additions and 0 deletions

View File

@ -22,6 +22,11 @@ lxc_architecture_mapping:
lxc_container_directory: "/var/lib/lxc"
lxc_container_cache_path: "/var/cache/lxc/download"
# The container backing store can be set to 'overlayfs' to use overlayfs
# This should only be done for production use with a linux kernel > 3.14
# which is when overlayfs was merged into the mainline kernel
# lxc_container_backing_store: overlayfs
# lxc container net network
lxc_net_bridge: lxcbr0
lxc_net_bridge_port: none

View File

@ -0,0 +1,11 @@
---
features:
- The container cache preparation process now allows ``overlayfs`` to be set
as the ``lxc_container_backing_store``. When this is set a base container
will be created using a name of the form
`<linux-distribution>`-`distribution-release>`-`<host-cpu-architecture>`.
The container will be stopped as it is not used for anything except to be
a backing store for all other containers which will be based on a snapshot
of the base container. The ``overlayfs`` backing store is not recommended
to be used for production unless the host kernel version is 3.18 or
higher.

View File

@ -33,3 +33,18 @@
- skip_ansible_lint
- lxc-cache
- lxc-image-cache-create
- name: Create base container to use for overlayfs containers
lxc_container:
name: "{{ lxc_cache_map.distro }}-{{ lxc_cache_map.release }}-{{ lxc_cache_map.arch }}"
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
when:
- lxc_container_backing_store is defined
- lxc_container_backing_store == 'overlayfs'