Merge "Use ansible_facts[] instead of fact variables"

This commit is contained in:
Zuul 2021-03-19 20:28:28 +00:00 committed by Gerrit Code Review
commit 1e1db042e5
16 changed files with 33 additions and 37 deletions

View File

@ -43,7 +43,7 @@ lxc_host_machine_volume_size: |-
{%- set mounts = [] -%}
{%- set mount_points = ['/var/lib/machines', '/var/lib/', '/var', '/'] -%}
{%- for mount in mount_points -%}
{%- for dev in ansible_mounts -%}
{%- for dev in ansible_facts['mounts'] -%}
{%- if mount == dev.mount -%}
{%- set _ = mounts.append(dev.size_total // (1024 ** 3)) -%}
{%- endif -%}
@ -246,7 +246,7 @@ lxc_cache_locales: "{{ _lxc_cache_locales | default(['en_US.UTF-8']) }}"
# Centos EPEL repository options
lxc_centos_epel_mirror: "{{ centos_epel_mirror | default('http://download.fedoraproject.org/pub/epel') }}"
lxc_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_distribution_major_version) }}"
lxc_centos_epel_key: "{{ centos_epel_key | default('http://download.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-' ~ ansible_facts['distribution_major_version']) }}"
# LXC must be installed from a COPR repository on CentOS since the version
# provided in EPEL is much too old (1.x).

View File

@ -35,4 +35,4 @@ galaxy_info:
dependencies:
- role: apt_package_pinning
when:
- ansible_pkg_mgr == 'apt'
- ansible_facts['pkg_mgr'] == 'apt'

View File

@ -16,7 +16,7 @@
- name: Set LXC cache fact(s)
set_fact:
cache_path_fact: "{{ lxc_container_cache_path }}/{{ lxc_cache_map.distro }}/{{ lxc_cache_map.release }}/{{ lxc_cache_map.arch }}/{{ lxc_cache_default_variant }}"
cache_time: "{{ ansible_date_time.epoch }}"
cache_time: "{{ ansible_facts['date_time']['epoch'] }}"
- name: Retrieve the expiry object
slurp:

View File

@ -96,7 +96,7 @@
mode: "0440"
src: sudoers.j2
when:
- ansible_pkg_mgr == 'yum'
- ansible_facts['pkg_mgr'] == 'yum'
- name: Adjust sshd configuration in container
lineinfile:

View File

@ -58,8 +58,8 @@
- name: Install the EPEL repository - Centos-8
yum_repository:
name: epel-lxc_hosts
baseurl: "{{ lxc_centos_epel_mirror ~ '/' ~ ansible_distribution_major_version ~ '/Everything/' ~ ansible_architecture }}"
description: 'Extra Packages for Enterprise Linux {{ ansible_distribution_major_version }} - $basearch'
baseurl: "{{ lxc_centos_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}"
description: "Extra Packages for Enterprise Linux {{ ansible_facts['distribution_major_version'] }} - $basearch"
gpgcheck: yes
gpgkey: "file:///etc/pki/rpm-gpg/{{ lxc_centos_epel_key.split('/')[-1] }}"
enabled: yes

View File

@ -83,7 +83,7 @@
line: "source /etc/network/interfaces.d/*.cfg"
backup: "yes"
when:
- ansible_os_family == "Debian"
- ansible_facts['os_family'] == "Debian"
tags:
- lxc-net
- lxc-interfaces

View File

@ -57,7 +57,7 @@
regexp: "^.*DefaultTasksMax.*$"
line: "DefaultTasksMax={{ lxc_default_tasks_max }}"
when:
- ansible_service_mgr == 'systemd'
- ansible_facts['service_mgr'] == 'systemd'
notify:
- Reload systemd units
tags:

View File

@ -34,11 +34,11 @@
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}-host.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}-host.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}-host.yml"
- "{{ ansible_distribution | lower }}-host.yml"
- "{{ ansible_os_family | lower }}-host.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}-host.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}-host.yml"
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}-host.yml"
- "{{ ansible_facts['distribution'] | lower }}-host.yml"
- "{{ ansible_facts['os_family'] | lower }}-host.yml"
tags:
- always
@ -46,11 +46,11 @@
include_vars: "{{ item }}"
with_first_found:
- "{{ lxc_user_defined_container | default([]) }}"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
- "{{ ansible_facts['distribution'] | lower }}.yml"
- "{{ ansible_facts['os_family'] | lower }}.yml"
tags:
- always
@ -58,7 +58,7 @@
tags:
- lxc_hosts-install
- include_tasks: "lxc_install_{{ ansible_pkg_mgr }}.yml"
- include_tasks: "lxc_install_{{ ansible_facts['pkg_mgr'] }}.yml"
tags:
- lxc_hosts-install
@ -82,7 +82,3 @@
- name: Flush handlers
meta: flush_handlers
- name: (RE)Gather facts post setup
setup:
gather_subset: "network,hardware,virtual"

View File

@ -16,7 +16,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true
apt-get update
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata
export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so
export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes

View File

@ -14,7 +14,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true
apt-get update
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata
export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so
export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes

View File

@ -14,7 +14,7 @@ apt-get remove -y --purge snap* lxc* lxd* resolvconf* || true
apt-get update
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes eatmydata
export LD_PRELOAD=/usr/lib/{{ ansible_architecture }}-linux-gnu/libeatmydata.so
export LD_PRELOAD=/usr/lib/{{ ansible_facts['architecture'] }}-linux-gnu/libeatmydata.so
apt-get install -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes gnupg
apt-get upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" --force-yes

View File

@ -29,11 +29,11 @@
apt:
update_cache: yes
when:
- ansible_pkg_mgr == 'apt'
- ansible_facts['pkg_mgr'] == 'apt'
- name: Ensure root ssh key
user:
name: "{{ ansible_env.USER | default('root') }}"
name: "{{ ansible_facts['env']['USER'] | default('root') }}"
generate_ssh_key: "yes"
ssh_key_bits: 2048
ssh_key_file: ".ssh/id_rsa"
@ -85,12 +85,12 @@
- name: DEBIAN - Get deployed interface file contents, without Ansible managed line
set_fact:
interface_file: "{{ lookup('pipe', 'cat /etc/network/interfaces.d/lxc-net-bridge.cfg | tail -n +3') }}"
when: ansible_os_family | lower == "debian"
when: ansible_facts['os_family'] | lower == "debian"
- name: RHEL - Get deployed interface file contents, without Ansible managed line
set_fact:
interface_file: "{{ lookup('pipe', 'cat /etc/sysconfig/network-scripts/ifcfg-lxcbr0 | tail -n +3') }}"
when: ansible_os_family | lower == "redhat"
when: ansible_facts['os_family'] | lower == "redhat"
- name: Get bridge interface facts
setup:

View File

@ -13,12 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
_lxc_hosts_container_image_url: "https://github.com/debuerreotype/docker-debian-artifacts/raw/dist-{{ lxc_cache_map.arch }}/{{ ansible_distribution_release }}/rootfs.tar.xz"
_lxc_hosts_container_image_url: "https://github.com/debuerreotype/docker-debian-artifacts/raw/dist-{{ lxc_cache_map.arch }}/{{ ansible_facts['distribution_release'] }}/rootfs.tar.xz"
_lxc_cache_map:
distro: debian
arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}"
release: "{{ ansible_distribution_major_version }}"
arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}"
release: "{{ ansible_facts['distribution_major_version'] }}"
copy_from_host:
- /etc/apt/sources.list
- /etc/apt/apt.conf.d/

View File

@ -28,7 +28,7 @@ _lxc_hosts_unarchive_extra_opts:
_lxc_cache_map:
distro: centos
arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}"
arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}"
release: 8
copy_from_host:
- /etc/default/locale

View File

@ -19,7 +19,7 @@ _lxc_hosts_container_image_checksum_regexp: "ubuntu-base-18.04.[0-9]-base-{{ lxc
_lxc_cache_map:
distro: ubuntu
arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}"
arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}"
release: bionic
copy_from_host:
- /etc/apt/sources.list

View File

@ -19,7 +19,7 @@ _lxc_hosts_container_image_checksum_regexp: "ubuntu-base-20.04.[0-9]-base-{{ lxc
_lxc_cache_map:
distro: ubuntu
arch: "{{ lxc_architecture_mapping.get( ansible_architecture ) }}"
arch: "{{ lxc_architecture_mapping.get( ansible_facts['architecture'] ) }}"
release: focal
copy_from_host:
- /etc/apt/sources.list