Change the default option name to reduce confusion
The default variable for different configuration keys between lxc 2 and 3 was being shared between lxc-hosts and lxc-container-create roles but the functionality of the option is slightly different between the roles. This change modifies the option to reduce confusion and ensures that if the option is overriden it doesn't cause silient failures. Change-Id: I3007843e99585ac96e499c2b1028bf3f92dd165b Signed-off-by: Kevin Carter <kevin@cloudnull.com>
This commit is contained in:
parent
1307acd38c
commit
7125cde0f6
@ -255,7 +255,7 @@ lxc_hosts_opensuse_mirror_obs_url: "{{ lxc_hosts_opensuse_mirror_url }}"
|
||||
|
||||
## A list of 'legacy' lxc configuration keys and their corresponding new
|
||||
## keys. Use this map to substitute keys suitable for other/newer lxc versions
|
||||
lxc_config_key_mapping:
|
||||
lxc_template_config_key_mapping:
|
||||
3:
|
||||
fstab: lxc.mount.fstab
|
||||
rootfs: lxc.rootfs.path
|
||||
|
@ -157,11 +157,11 @@ 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_config_key_mapping[lxc_major_version|int]['fstab'] }} = ${LXC_PATH}/fstab" >> "${LXC_PATH}/config"
|
||||
echo "{{ lxc_template_config_key_mapping[lxc_major_version|int]['fstab'] }} = ${LXC_PATH}/fstab" >> "${LXC_PATH}/config"
|
||||
fi
|
||||
|
||||
# Set the uts name
|
||||
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['uts_name'] }} = ${LXC_NAME}" >> "${LXC_PATH}/config"
|
||||
echo "{{ lxc_template_config_key_mapping[lxc_major_version|int]['uts_name'] }} = ${LXC_NAME}" >> "${LXC_PATH}/config"
|
||||
|
||||
# Look for extra templates
|
||||
TEMPLATE_FILES="${LXC_PATH}/config"
|
||||
@ -187,17 +187,17 @@ done
|
||||
IFS=${OLD_IFS}
|
||||
|
||||
# Add the machinectl backend store for the new container
|
||||
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"
|
||||
if grep -q '^{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs'] }} =' "${LXC_PATH}/config"; then
|
||||
sed -i "s|^{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs'] }} =.*|{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}|" "${LXC_PATH}/config"
|
||||
else
|
||||
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}" >> "${LXC_PATH}/config"
|
||||
echo "{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs'] }} = ${LXC_ROOTFS}" >> "${LXC_PATH}/config"
|
||||
fi
|
||||
|
||||
{% if (lxc_major_version | int) < 3 %}
|
||||
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"
|
||||
if grep -q '^{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =' "${LXC_PATH}/config"; then
|
||||
sed -i "s|^{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} =.*|{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs|" "${LXC_PATH}/config"
|
||||
else
|
||||
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs" >> "${LXC_PATH}/config"
|
||||
echo "{{ lxc_template_config_key_mapping[lxc_major_version|int]['rootfs_backend'] }} = btrfs" >> "${LXC_PATH}/config"
|
||||
fi
|
||||
{% endif %}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user