network/tests/tests_regression_nm.yml
Rich Megginson 39ac91d9af refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead
Ansible 2.20 has deprecated the use of Ansible facts as variables.  For
example, `ansible_distribution` is now deprecated in favor of
`ansible_facts["distribution"]`.  This is due to making the default
setting `INJECT_FACTS_AS_VARS=false`.  For now, this will create WARNING
messages, but in Ansible 2.24 it will be an error.

See https://docs.ansible.com/projects/ansible/latest/porting_guides/porting_guide_core_2.20.html#inject-facts-as-vars

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2026-01-07 18:43:15 -05:00

41 lines
1.7 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
# set network provider and gather facts
- name: Run playbook 'playbooks/tests_checkpoint_cleanup.yml' with nm as
provider
hosts: all
tasks:
- name: Include the task 'el_repo_setup.yml'
include_tasks: tasks/el_repo_setup.yml
- name: Set network provider to 'nm'
set_fact:
network_provider: nm
- name: Install NetworkManager
package:
name: NetworkManager
state: present
use: "{{ (__network_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
- name: Get package info
package_facts:
- name: Get NetworkManager version
set_fact:
networkmanager_version: "{{
ansible_facts.packages['NetworkManager'][0]['version'] }}"
# workaround for: https://github.com/ansible/ansible/issues/27973
# There is no way in Ansible to abort a playbook hosts with specific OS
# releases Therefore we include the playbook with the tests only if the hosts
# would support it.
# The test requires NetworkManager, therefore it cannot run on RHEL/CentOS 6
- name: Import the playbook 'playbooks/tests_checkpoint_cleanup.yml'
import_playbook: playbooks/tests_checkpoint_cleanup.yml
when:
- ansible_facts['distribution_major_version'] != '6'
# The test depends on behavior that is only visible with newer NM
- networkmanager_version is version('1.22.0', '>=')
- ansible_facts['distribution'] not in ['RedHat', 'CentOS', 'Fedora'] or
(ansible_facts['distribution'] == 'Fedora' and
ansible_facts['distribution_major_version'] | int < 41) or
ansible_facts['distribution_major_version'] | int < 9