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 <kevin@cloudnull.com>
This commit is contained in:
Kevin Carter 2018-10-09 14:38:42 -05:00 committed by Kevin Carter (cloudnull)
parent 89dc180ca4
commit 6405d287ec
2 changed files with 13 additions and 7 deletions

View File

@ -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

View File

@ -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)