diff --git a/defaults/main.yml b/defaults/main.yml index aa2cba53..ac421b18 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/releasenotes/notes/base-container-overlayfs-ec7eeda2f5807e96.yaml b/releasenotes/notes/base-container-overlayfs-ec7eeda2f5807e96.yaml new file mode 100644 index 00000000..d6770795 --- /dev/null +++ b/releasenotes/notes/base-container-overlayfs-ec7eeda2f5807e96.yaml @@ -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 + ``-`distribution-release>`-``. + 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. diff --git a/tasks/lxc_cache_create.yml b/tasks/lxc_cache_create.yml index 30d6776b..992fb179 100644 --- a/tasks/lxc_cache_create.yml +++ b/tasks/lxc_cache_create.yml @@ -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'