network/tests/tasks
Rich Megginson 88a2609327 test: ensure role gathers the facts it uses by having test clear_facts before include_role
The role gathers the facts it uses.  For example, if the user uses
`ANSIBLE_GATHERING=explicit`, the role uses the `setup` module with the
facts and subsets it requires.

This change allows us to test this.  Before every role invocation, the test
will use `meta: clear_facts` so that the role starts with no facts.

Create a task file tests/tasks/run_role_with_clear_facts.yml to do the tasks
to clear the facts and run the role.  Note that this means we don't need to
use `gather_facts` for the tests.

Some vars defined using `ansible_facts` have been changed to be defined with
`set_fact` instead.  This is because of the fact that `vars` are lazily
evaluated - the var might be referenced when the facts have been cleared, and
will issue an error like `ansible_facts["distribution"] is undefined`.  This is
typically done for blocks that have a `when` condition that uses `ansible_facts`
and the block has a role invocation using run_role_with_clear_facts.yml
These have been rewritten to define the `when` condition using `set_fact`.  This
is because the `when` condition is evaluated every time a task is invoked in the
block, and if the facts are cleared, this will raise an undefined variable error.

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
2026-03-19 10:47:09 -06:00
..
provider test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
activate_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
assert_autoconnect_retries.yml feat: Support autoconnect_retries 2024-10-08 10:25:58 -04:00
assert_bond_options.yml test: fix some Ansible warnings not caught by lint 2024-07-25 08:35:17 -06:00
assert_bond_port_profile_present.yml test: fix some Ansible warnings not caught by lint 2024-07-25 08:35:17 -06:00
assert_controller_device_present.yml test: Rewrite tests_bond_options.yml in the new testing format 2024-02-14 20:20:49 -07:00
assert_device_absent.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
assert_device_present.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
assert_dhcp_device_present.yml test: Rewrite tests_bond_options.yml in the new testing format 2024-02-14 20:20:49 -07:00
assert_IPv4_present.yml test: fix some Ansible warnings not caught by lint 2024-07-25 08:35:17 -06:00
assert_IPv6_present.yml test: fix some Ansible warnings not caught by lint 2024-07-25 08:35:17 -06:00
assert_may_fail.yml feat: Support wait_ip property 2024-10-29 09:43:38 -04:00
assert_network_connections_failed.yml fix: Ask user's consent to restart NM due to wireless or team interfaces 2024-03-15 17:33:36 -04:00
assert_network_connections_succeeded.yml fix: Remove MAC address matching from SysUtil.link_info_find() 2025-03-31 22:21:18 -04:00
assert_output_in_stderr_without_warnings.yml refactor: support Ansible 2.19 2025-07-02 14:42:43 -06:00
assert_package_installed.yml fix: Ask user's consent to restart NM due to wireless or team interfaces 2024-03-15 17:33:36 -04:00
assert_profile_absent.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
assert_profile_present.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
check_network_dns.yml test: Add DNS, routes and network connectivity checks during cleanup 2024-02-14 20:20:49 -07:00
cleanup_802_1x_server.yml test: improve bond test failure debugging 2024-02-27 13:17:16 -05:00
cleanup_bond_profile+device.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
cleanup_mock_wifi.yml Cleaning up ansible-lint errors except '106', '303' and '403' 2021-04-15 20:53:53 +02:00
cleanup_profile+device.yml add support for ansible-core 2.11 ansible-lint, ansible-test 2021-10-11 12:03:00 -06:00
cleanup_vlan_and_parent_profile+device.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_and_remove_interface.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
create_bond_port_match_by_mac.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_bond_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_bond_profile_reconfigure.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_bridge_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_bridge_profile_no_autoconnect.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_dummy_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_mac_address_match.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_team_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
create_test_interfaces_with_dhcp.yml refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead 2026-01-07 18:43:15 -05:00
create_wireless_profile_restart_network.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
delete_interface.yml ansible-lint: Fix name[casing] warnings 2023-03-27 16:25:03 +02:00
down_profile+delete_interface.yml refactor: support Ansible 2.19 2025-07-02 14:42:43 -06:00
down_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
el_repo_setup.yml refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead 2026-01-07 18:43:15 -05:00
find+remove_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
get_current_interfaces.yml Cleaning up ansible-lint errors except '106', '303' and '403' 2021-04-15 20:53:53 +02:00
get_interface_stat.yml Rename files to be valid python identifiers 2020-04-22 17:40:03 +02:00
get_modules_and_utils_paths.yml test: set shell to /bin/bash in order to use pipefail 2025-04-14 10:05:37 -06:00
get_NetworkManager_NVR.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
get_profile_stat.yml Fingerprint RHEL System Role managed config files 2023-03-30 13:38:19 -06:00
manage_test_interface.yml ci: Check spelling with codespell 2025-02-14 11:06:01 +00:00
ostree_systems_check.yml test: improve name text for skipped ostree tests 2024-03-25 17:30:00 -06:00
remove+down_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
remove_package.yml fix: Ask user's consent to restart NM due to wireless or team interfaces 2024-03-15 17:33:36 -04:00
remove_profile.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
remove_test_interfaces_with_dhcp.yml test: use is-active instead of is-enabled to check for firewalld 2024-08-20 11:16:28 -06:00
run_role_with_clear_facts.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00
run_test.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
setup_802.1x.yml style: ansible-lint - fix missing YAML document start 2023-04-28 09:15:50 -06:00
setup_802_1x_server.yml refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead 2026-01-07 18:43:15 -05:00
setup_mock_wifi.yml test: Retry until success when installing package 2024-02-14 20:20:49 -07:00
setup_mock_wifi_wpa3_owe.yml refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead 2026-01-07 18:43:15 -05:00
setup_mock_wifi_wpa3_sae.yml refactor: handle INJECT_FACTS_AS_VARS=false by using ansible_facts instead 2026-01-07 18:43:15 -05:00
setup_test_interface.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
show_interfaces.yml ansible-lint: Fix name[missing] and name[play] failures 2023-04-10 17:49:07 +02:00
start_mock_wifi.yml wifi: Add Opportunistic Wireless Encryption (OWE) support 2021-05-24 10:51:01 +08:00
test_802.1x_capath.yml test: ensure role gathers the facts it uses by having test clear_facts before include_role 2026-03-19 10:47:09 -06:00