Use ansible_facts[] instead of fact variables

See https://github.com/ansible/ansible/issues/73654

Change-Id: If6b30e40bf71f60ee72fdc1459ce5e5a9f4f7d93
This commit is contained in:
Jonathan Rosser 2021-02-22 16:44:30 +00:00
parent 9a397730b4
commit 5d22a389c2
7 changed files with 13 additions and 30 deletions

View File

@ -160,7 +160,7 @@ lxc_container_enable_resolved: true
# User defined variable pointing to a specific variable file used when setting
# up the base container image. Deployers can use the provided container variable
# files by simply inputting the file name
# "{{ ansible_distribution }}-{{ ansible_distribution_version }}-container.yml"
# "{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}-container.yml"
# or by providing the full path to a local file containing all of the variables
# needed to prepare a container.
#lxc_user_defined_container: null

View File

@ -30,32 +30,15 @@
tags:
- always
- name: Collect physical host facts if missing
action:
module: setup
delegate_to: "{{ physical_host }}"
delegate_facts: yes
when:
- hostvars[physical_host]['ansible_kernel'] is not defined
- name: Kernel version and LXC backing store check
debug:
msg: "Using overlayfs is not recommended when using Kernel version < 3.18"
when:
- lxc_container_backing_store == "overlayfs"
- hostvars[physical_host]['ansible_kernel'] is version('3.18.0-0-generic', '<')
tags:
- always
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- "{{ lxc_user_defined_container | default([]) }}"
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_major_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_os_family'] | lower }}-{{ hostvars[physical_host]['ansible_distribution_major_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_distribution'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_os_family'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_facts']['distribution'] | lower }}-{{ hostvars[physical_host]['ansible_facts']['distribution_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_facts']['distribution'] | lower }}-{{ hostvars[physical_host]['ansible_facts']['distribution_major_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_facts']['os_family'] | lower }}-{{ hostvars[physical_host]['ansible_facts']['distribution_major_version'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_facts']['distribution'] | lower }}.yml"
- "{{ hostvars[physical_host]['ansible_facts']['os_family'] | lower }}.yml"
tags:
- always

View File

@ -22,7 +22,7 @@
- block:
- name: Install BTRFS packages
package:
name: "{{ btrfs_package[ansible_pkg_mgr | lower] }}"
name: "{{ btrfs_package[ansible_facts['pkg_mgr'] | lower] }}"
state: present
- name: Create base directories

View File

@ -15,8 +15,8 @@
lxc_container_map:
distro: debian
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_architecture'] | lower ) }}"
release: "{{ hostvars[physical_host]['ansible_distribution_major_version'] }}"
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_facts']['architecture'] | lower ) }}"
release: "{{ hostvars[physical_host]['ansible_facts']['distribution_major_version'] }}"
lxc_container_default_config_list:
- "lxc.start.auto=1"

View File

@ -18,7 +18,7 @@ lxc_container_backing_store: machinectl
lxc_container_map:
distro: gentoo
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_architecture'] | lower ) }}"
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_facts']['architecture'] | lower ) }}"
release: 17.0-systemd
lxc_container_default_config_list:

View File

@ -19,7 +19,7 @@ lxc_container_enable_resolved: false
lxc_container_map:
distro: opensuse
arch: amd64
release: "{{ hostvars[physical_host]['ansible_distribution_version'] }}"
release: "{{ hostvars[physical_host]['ansible_facts']['distribution_version'] }}"
lxc_container_default_config_list:
- "lxc.autodev=1"

View File

@ -15,8 +15,8 @@
lxc_container_map:
distro: ubuntu
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_architecture'] | lower ) }}"
release: "{{ hostvars[physical_host].ansible_distribution_release }}"
arch: "{{ lxc_architecture_mapping.get( hostvars[physical_host]['ansible_facts']['architecture'] | lower ) }}"
release: "{{ hostvars[physical_host]['ansible_facts']['distribution_release'] }}"
lxc_container_default_config_list:
- "lxc.start.auto=1"