Merge "Convert lxc2 to lxc3 config keys dynamically"
This commit is contained in:
commit
7dc84c2ae9
|
@ -25,6 +25,14 @@ lxc_container_wait_params:
|
||||||
timeout: 60
|
timeout: 60
|
||||||
|
|
||||||
|
|
||||||
|
## 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:
|
||||||
|
lxc.aa_profile: lxc.apparmor.profile
|
||||||
|
lxc.haltsignal: lxc.signal.halt
|
||||||
|
2:
|
||||||
|
|
||||||
lxc_container_config: /etc/lxc/lxc-openstack.conf
|
lxc_container_config: /etc/lxc/lxc-openstack.conf
|
||||||
lxc_container_config_list: []
|
lxc_container_config_list: []
|
||||||
lxc_container_commands: ""
|
lxc_container_commands: ""
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
- name: Write default container config
|
- name: Write default container config
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
|
dest: "/var/lib/lxc/{{ inventory_hostname }}/config"
|
||||||
line: "{{ item | replace('=', ' = ', 1) | regex_replace('\\s+', ' ') }}"
|
line: "{{ lxc_config_key_mapping[lxc_major_version|int][item.split('=', 1)[0]] | default(item.split('=', 1)[0]) }} = {{ item.split('=', 1)[-1] }}"
|
||||||
backup: "true"
|
backup: "true"
|
||||||
with_items: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
|
with_items: "{{ lxc_container_default_config_list | union(lxc_container_config_list) }}"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
# NOTE(cloudnull): To dynamically set the mac address "facts" Ansible line
|
# NOTE(cloudnull): To dynamically set the mac address "facts" Ansible line
|
||||||
# format is being used
|
# format is being used
|
||||||
- name: Set fixed hardware address fact
|
- name: Set fixed hardware address fact
|
||||||
set_fact: "{{item.item.value.interface }}_mac_address={{ item.content | b64decode }}"
|
set_fact: "{{ item.item.value.interface }}_mac_address={{ item.content | b64decode }}"
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ macs.results }}"
|
- "{{ macs.results }}"
|
||||||
|
|
||||||
|
@ -182,7 +182,7 @@
|
||||||
with_items:
|
with_items:
|
||||||
- "lxc.hook.pre-start = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
- "lxc.hook.pre-start = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
||||||
- "lxc.hook.post-stop = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
- "lxc.hook.post-stop = /var/lib/lxc/{{ inventory_hostname }}/veth-cleanup.sh"
|
||||||
- "{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary ('lxc.signal.halt', 'lxc.haltsignal') }} = SIGRTMIN+4"
|
- "{{ lxc_config_key_mapping[lxc_major_version|int]['lxc.haltsignal'] | default('lxc.haltsignal') }} = SIGRTMIN+4"
|
||||||
delegate_to: "{{ physical_host }}"
|
delegate_to: "{{ physical_host }}"
|
||||||
|
|
||||||
- name: Run veth wiring
|
- name: Run veth wiring
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
- name: Enable or Disable lxc three syntax
|
- name: Enable or Disable lxc three syntax
|
||||||
set_fact:
|
set_fact:
|
||||||
lxc_three_syntax: "{{ (lxc_version.stdout.split('.')[0] | int) >= 3 }}"
|
lxc_three_syntax: "{{ (lxc_version.stdout.split('.')[0] | int) >= 3 }}"
|
||||||
|
lxc_major_version: "{{ lxc_version.stdout.split('.')[0] }}"
|
||||||
|
|
||||||
- name: Allow the usage of local facts
|
- name: Allow the usage of local facts
|
||||||
file:
|
file:
|
||||||
|
|
|
@ -4,4 +4,5 @@ ansible_become: True
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
lxc_container_config_list:
|
lxc_container_config_list:
|
||||||
# The unconfined profile is causing problems with overlayfs. See https://bugs.launchpad.net/openstack-ansible/+bug/1612412
|
# The unconfined profile is causing problems with overlayfs. See https://bugs.launchpad.net/openstack-ansible/+bug/1612412
|
||||||
- "{{ (hostvars[physical_host | default('localhost')]['ansible_distribution_version'] == '18.04') | ternary('lxc.apparmor.profile', 'lxc.aa_profile') }}={{ (lxc_container_backing_store == 'overlayfs') | ternary('lxc-openstack', 'unconfined') }}"
|
# Use the lxc2 aa_profile key to test that it is correctly changed in-flight to the required lxc3 key on bionic
|
||||||
|
- "lxc.aa_profile={{ (lxc_container_backing_store == 'overlayfs') | ternary('lxc-openstack', 'unconfined') }}"
|
||||||
|
|
Loading…
Reference in New Issue