Update the option uts name in the machinectl template

The machinectl template was running with the legacy uts name option.
This change updates that option so that it uses the hash and major
version to update the config variable.

Change-Id: I85b5c92422116b139e447330214b2d6b5afbf948
Signed-off-by: Kevin Carter <kevin@cloudnull.com>
This commit is contained in:
Kevin Carter 2018-10-09 13:56:48 -05:00 committed by Kevin Carter (cloudnull)
parent 925df08ac3
commit 89dc180ca4
3 changed files with 21 additions and 2 deletions

View File

@ -252,3 +252,11 @@ lxc_centos_package_key: https://copr-be.cloud.fedoraproject.org/results/thm/lxc2
# 'lxc_hosts_opensuse_mirror_obs_url' to its default value.
lxc_hosts_opensuse_mirror_url: "{{ opensuse_mirror | default('http://download.opensuse.org') }}"
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:
3:
uts_name: lxc.uts.name
2:
uts_name: lxc.utsname

View File

@ -38,8 +38,19 @@
- lxc-files
- lxc-config
- name: Pull lxc version
command: "lxc-ls --version"
changed_when: false
register: lxc_version
tags:
- skip_ansible_lint
- name: Enable or Disable lxc three syntax
set_fact:
lxc_major_version: "{{ lxc_version.stdout.split('.')[0] }}"
- name: Create machinectl base template
copy:
template:
src: "lxc-machinectl.j2"
dest: "/usr/share/lxc/templates/lxc-machinectl"
owner: "root"

View File

@ -161,7 +161,7 @@ if [ -e "${LXC_CACHE_PATH}/fstab" ]; then
fi
# Set the uts name
echo "lxc.utsname = ${LXC_NAME}" >> "${LXC_PATH}/config"
echo "{{ lxc_config_key_mapping[lxc_major_version|int]['uts_name'] }} = ${LXC_NAME}" >> "${LXC_PATH}/config"
# Look for extra templates
TEMPLATE_FILES="${LXC_PATH}/config"