Use ansible_facts[] instead of fact variables
See https://github.com/ansible/ansible/issues/73654 Change-Id: I36a098e4b028bdf09b38e2f2c99f68f311ce9d32
This commit is contained in:
parent
5b327a5ca5
commit
63ad4cffac
@ -45,10 +45,10 @@
|
|||||||
- name: Update initramfs
|
- name: Update initramfs
|
||||||
command: "{{ systemd_networkd_update_initramfs }}"
|
command: "{{ systemd_networkd_update_initramfs }}"
|
||||||
when:
|
when:
|
||||||
- ansible_virtualization_type != "systemd-nspawn"
|
- ansible_facts['virtualization_type'] != "systemd-nspawn"
|
||||||
- ansible_virtualization_type != "lxc"
|
- ansible_facts['virtualization_type'] != "lxc"
|
||||||
- ansible_virtualization_type != "lxd"
|
- ansible_facts['virtualization_type'] != "lxd"
|
||||||
- ansible_virtualization_type != "podman"
|
- ansible_facts['virtualization_type'] != "podman"
|
||||||
- ansible_virtualization_type != "docker"
|
- ansible_facts['virtualization_type'] != "docker"
|
||||||
- ansible_virtualization_type != "systemd_container"
|
- ansible_facts['virtualization_type'] != "systemd_container"
|
||||||
- ansible_virtualization_type != "container"
|
- ansible_facts['virtualization_type'] != "container"
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
include_vars: "{{ item }}"
|
include_vars: "{{ item }}"
|
||||||
with_first_found:
|
with_first_found:
|
||||||
- files:
|
- files:
|
||||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_version | lower }}.yml"
|
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_version'] | lower }}.yml"
|
||||||
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
- "{{ ansible_facts['distribution'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||||
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
|
- "{{ ansible_facts['os_family'] | lower }}-{{ ansible_facts['distribution_major_version'] | lower }}.yml"
|
||||||
- "{{ ansible_distribution | lower }}.yml"
|
- "{{ ansible_facts['distribution'] | lower }}.yml"
|
||||||
- "{{ ansible_os_family | lower }}.yml"
|
- "{{ ansible_facts['os_family'] | lower }}.yml"
|
||||||
skip: true
|
skip: true
|
||||||
tags:
|
tags:
|
||||||
- always
|
- always
|
||||||
@ -35,16 +35,16 @@
|
|||||||
mode: '0644'
|
mode: '0644'
|
||||||
with_items: "{{ systemd_networkd_package_repos_keys | selectattr('keyfile','defined') | list }}"
|
with_items: "{{ systemd_networkd_package_repos_keys | selectattr('keyfile','defined') | list }}"
|
||||||
when:
|
when:
|
||||||
- ansible_os_family | lower == 'redhat'
|
- ansible_facts['os_family'] | lower == 'redhat'
|
||||||
- ansible_distribution_major_version is version('8', '>=')
|
- ansible_facts['distribution_major_version'] is version('8', '>=')
|
||||||
|
|
||||||
- name: Ensure GPG keys have the correct SELinux contexts applied
|
- name: Ensure GPG keys have the correct SELinux contexts applied
|
||||||
command: restorecon -Rv /etc/pki/rpm-gpg/
|
command: restorecon -Rv /etc/pki/rpm-gpg/
|
||||||
# TODO(evrardjp): Be more idempotent
|
# TODO(evrardjp): Be more idempotent
|
||||||
changed_when: false
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- ansible_os_family | lower == 'redhat'
|
- ansible_facts['os_family'] | lower == 'redhat'
|
||||||
- ansible_distribution_major_version is version('8', '>=')
|
- ansible_facts['distribution_major_version'] is version('8', '>=')
|
||||||
|
|
||||||
# Handle gpg keys manually
|
# Handle gpg keys manually
|
||||||
- name: Install gpg keys
|
- name: Install gpg keys
|
||||||
@ -60,21 +60,21 @@
|
|||||||
retries: 5
|
retries: 5
|
||||||
delay: 2
|
delay: 2
|
||||||
when:
|
when:
|
||||||
- ansible_os_family | lower == 'redhat'
|
- ansible_facts['os_family'] | lower == 'redhat'
|
||||||
- ansible_distribution_major_version is version('8', '>=')
|
- ansible_facts['distribution_major_version'] is version('8', '>=')
|
||||||
|
|
||||||
- name: Install the EPEL repository
|
- name: Install the EPEL repository
|
||||||
yum_repository:
|
yum_repository:
|
||||||
name: epel-networkd
|
name: epel-networkd
|
||||||
baseurl: "{{ systemd_networkd_epel_mirror ~ '/' ~ ansible_distribution_major_version ~ '/Everything/' ~ ansible_architecture }}"
|
baseurl: "{{ systemd_networkd_epel_mirror ~ '/' ~ ansible_facts['distribution_major_version'] ~ '/Everything/' ~ ansible_facts['architecture'] }}"
|
||||||
description: 'Extra Packages for Enterprise Linux $releasever - $basearch'
|
description: 'Extra Packages for Enterprise Linux $releasever - $basearch'
|
||||||
gpgcheck: yes
|
gpgcheck: yes
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: present
|
state: present
|
||||||
includepkgs: 'systemd-networkd'
|
includepkgs: 'systemd-networkd'
|
||||||
when:
|
when:
|
||||||
- ansible_os_family | lower == 'redhat'
|
- ansible_facts['os_family'] | lower == 'redhat'
|
||||||
- ansible_distribution_major_version is version('8', '>=')
|
- ansible_facts['distribution_major_version'] is version('8', '>=')
|
||||||
register: install_epel_repo
|
register: install_epel_repo
|
||||||
until: install_epel_repo is success
|
until: install_epel_repo is success
|
||||||
retries: 5
|
retries: 5
|
||||||
@ -84,8 +84,8 @@
|
|||||||
package:
|
package:
|
||||||
name: "{{ systemd_networkd_distro_packages }}"
|
name: "{{ systemd_networkd_distro_packages }}"
|
||||||
state: "present"
|
state: "present"
|
||||||
update_cache: "{{ (ansible_pkg_mgr == 'apt') | ternary('yes', omit) }}"
|
update_cache: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary('yes', omit) }}"
|
||||||
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(600, omit) }}"
|
cache_valid_time: "{{ (ansible_facts['pkg_mgr'] == 'apt') | ternary(600, omit) }}"
|
||||||
enablerepo: "{{ systemd_networkd_enablerepo | default(omit) }}"
|
enablerepo: "{{ systemd_networkd_enablerepo | default(omit) }}"
|
||||||
when:
|
when:
|
||||||
- systemd_networkd_distro_packages | length > 0
|
- systemd_networkd_distro_packages | length > 0
|
||||||
@ -205,5 +205,5 @@
|
|||||||
reload: yes
|
reload: yes
|
||||||
with_indexed_items: "{{ systemd_networks }}"
|
with_indexed_items: "{{ systemd_networks }}"
|
||||||
when:
|
when:
|
||||||
- (ansible_os_family | lower) == 'redhat'
|
- (ansible_facts['os_family'] | lower) == 'redhat'
|
||||||
- item.1.ipforward | default(false) | bool
|
- item.1.ipforward | default(false) | bool
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
- interface: "br-dummy"
|
- interface: "br-dummy"
|
||||||
address: "10.0.0.100"
|
address: "10.0.0.100"
|
||||||
netmask: "255.255.255.0"
|
netmask: "255.255.255.0"
|
||||||
gateway: "{{ ansible_default_ipv4.gateway | default('10.0.0.1') }}"
|
gateway: "{{ ansible_facts['default_ipv4']['gateway'] | default('10.0.0.1') }}"
|
||||||
mtu: 9000
|
mtu: 9000
|
||||||
usedns: true
|
usedns: true
|
||||||
static_routes:
|
static_routes:
|
||||||
@ -101,34 +101,34 @@
|
|||||||
- name: Interface check
|
- name: Interface check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_dummy0['active']
|
- ansible_facts['dummy0']['active']
|
||||||
- ansible_dummy0['type'] == 'ether'
|
- ansible_facts['dummy0']['type'] == 'ether'
|
||||||
- ansible_dummy0['mtu'] == 9000
|
- ansible_facts['dummy0']['mtu'] == 9000
|
||||||
- ansible_dummy1['active']
|
- ansible_facts['dummy1']['active']
|
||||||
- ansible_dummy1['type'] == 'ether'
|
- ansible_facts['dummy1']['type'] == 'ether'
|
||||||
- ansible_dummy1['mtu'] == 9000
|
- ansible_facts['dummy1']['mtu'] == 9000
|
||||||
- ansible_dummy2['active']
|
- ansible_facts['dummy2']['active']
|
||||||
- ansible_dummy2['type'] == 'ether'
|
- ansible_facts['dummy2']['type'] == 'ether'
|
||||||
- name: Bond check
|
- name: Bond check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_bond0['active']
|
- ansible_facts['bond0']['active']
|
||||||
- ansible_bond0['type'] == 'bonding'
|
- ansible_facts['bond0']['type'] == 'bonding'
|
||||||
- ansible_bond0['mtu'] == 9000
|
- ansible_facts['bond0']['mtu'] == 9000
|
||||||
- name: Bridge check
|
- name: Bridge check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_br_dummy['active']
|
- ansible_facts['br_dummy']['active']
|
||||||
- ansible_br_dummy['type'] == 'bridge'
|
- ansible_facts['br_dummy']['type'] == 'bridge'
|
||||||
- ansible_br_dummy['ipv4']['address'] == '10.0.0.100'
|
- ansible_facts['br_dummy']['ipv4']['address'] == '10.0.0.100'
|
||||||
- ansible_br_dummy['ipv4']['netmask'] == '255.255.255.0'
|
- ansible_facts['br_dummy']['ipv4']['netmask'] == '255.255.255.0'
|
||||||
- name: Bridge check
|
- name: Bridge check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_br_test['active']
|
- ansible_facts['br_test']['active']
|
||||||
- ansible_br_test['type'] == 'bridge'
|
- ansible_facts['br_test']['type'] == 'bridge'
|
||||||
- ansible_br_test['ipv4']['address'] == '10.1.0.1'
|
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
||||||
- ansible_br_test['ipv4']['netmask'] == '255.255.255.0'
|
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
||||||
- name: Check link config overrides
|
- name: Check link config overrides
|
||||||
shell: 'grep -wo "Alias" /etc/systemd/network/*br-dummy.link'
|
shell: 'grep -wo "Alias" /etc/systemd/network/*br-dummy.link'
|
||||||
changed_when: false
|
changed_when: false
|
||||||
@ -158,16 +158,16 @@
|
|||||||
- name: Interface check
|
- name: Interface check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_br_test is defined
|
- ansible_facts['br_test'] is defined
|
||||||
- ansible_dummy2['active']
|
- ansible_facts['dummy2']['active']
|
||||||
- ansible_dummy2['type'] == 'ether'
|
- ansible_facts['dummy2']['type'] == 'ether'
|
||||||
- name: Bridge check
|
- name: Bridge check
|
||||||
assert:
|
assert:
|
||||||
that:
|
that:
|
||||||
- ansible_br_test['active']
|
- ansible_facts['br_test']['active']
|
||||||
- ansible_br_test['type'] == 'bridge'
|
- ansible_facts['br_test']['type'] == 'bridge'
|
||||||
- ansible_br_test['ipv4']['address'] == '10.1.0.1'
|
- ansible_facts['br_test']['ipv4']['address'] == '10.1.0.1'
|
||||||
- ansible_br_test['ipv4']['netmask'] == '255.255.255.0'
|
- ansible_facts['br_test']['ipv4']['netmask'] == '255.255.255.0'
|
||||||
vars:
|
vars:
|
||||||
systemd_interface_cleanup: true
|
systemd_interface_cleanup: true
|
||||||
systemd_run_networkd: yes
|
systemd_run_networkd: yes
|
||||||
|
Loading…
Reference in New Issue
Block a user