From 6405d287ec66ddb4a3181be7d6d725f5bb907412 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Tue, 9 Oct 2018 14:38:42 -0500 Subject: [PATCH] Add fstab and rootfs options to the lxc3 updates The fstab and rootfs options have slightly changed in lxc3 this change updates our templtes to ensure we're using the correct option for the LXC version found on disk. Change-Id: Ib1c563db70f3ddbeb3a65c55e0917777b27fd41f Signed-off-by: Kevin Carter --- defaults/main.yml | 6 ++++++ templates/lxc-machinectl.j2 | 14 +++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 9f324e5e..8b168e1b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -257,6 +257,12 @@ lxc_hosts_opensuse_mirror_obs_url: "{{ lxc_hosts_opensuse_mirror_url }}" ## keys. Use this map to substitute keys suitable for other/newer lxc versions lxc_config_key_mapping: 3: + fstab: lxc.mount.fstab + rootfs: lxc.rootfs.path + rootfs_backend: lxc.rootfs.backend uts_name: lxc.uts.name 2: + fstab: lxc.mount.fstab + rootfs: lxc.rootfs + rootfs_backend: lxc.rootfs.backend uts_name: lxc.utsname diff --git a/templates/lxc-machinectl.j2 b/templates/lxc-machinectl.j2 index c0ca05a7..936eb17d 100644 --- a/templates/lxc-machinectl.j2 +++ b/templates/lxc-machinectl.j2 @@ -157,7 +157,7 @@ echo -e "\n# Container specific configuration" >> "${LXC_PATH}/config" # If an older fstab file exists in the template, extend the lxc config. if [ -e "${LXC_CACHE_PATH}/fstab" ]; then - echo "lxc.mount.fstab = ${LXC_PATH}/fstab" >> "${LXC_PATH}/config" + echo "{{ lxc_config_key_mapping[lxc_major_version|int]['fstab'] }} = ${LXC_PATH}/fstab" >> "${LXC_PATH}/config" fi # Set the uts name @@ -187,15 +187,15 @@ done IFS=${OLD_IFS} # Add the machinectl backend store for the new containe -if grep -q '^lxc\.rootfs =' "${LXC_PATH}/config"; then - sed -i "s|^lxc\.rootfs =.*|lxc.rootfs = ${LXC_ROOTFS}|" "${LXC_PATH}/config" +if grep -q '^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} =' "${LXC_PATH}/config"; then + sed -i "s|^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} =.*|{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}|" "${LXC_PATH}/config" else - echo "lxc.rootfs = ${LXC_ROOTFS}" >> "${LXC_PATH}/config" + echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}" >> "${LXC_PATH}/config" fi -if grep -q '^lxc\.rootfs\.backend =' "${LXC_PATH}/config"; then - sed -i "s|^lxc\.rootfs\.backend =.*|lxc.rootfs.backend = btrfs|" "${LXC_PATH}/config" +if grep -q '^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =' "${LXC_PATH}/config"; then + sed -i "s|^{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =.*|{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs|" "${LXC_PATH}/config" else - echo "lxc.rootfs.backend = btrfs" >> "${LXC_PATH}/config" + echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs" >> "${LXC_PATH}/config" fi # Prevent mingetty from calling vhangup(2)