diff --git a/tests/ensure_provider_tests.py b/tests/ensure_provider_tests.py index 3f9a6099c..b6bce69c8 100755 --- a/tests/ensure_provider_tests.py +++ b/tests/ensure_provider_tests.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: BSD-3-Clause """Check that there is a playbook to run all role tests with both providers""" + # vim: fileencoding=utf8 import difflib @@ -8,11 +9,10 @@ import os import sys - GET_NM_VERSION = """ - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -30,8 +30,7 @@ ansible_facts.packages['NetworkManager'][0]['version'] }}" """ -MINIMUM_NM_VERSION_CHECK = """ - - networkmanager_version is version({minimum_nm_version}, '>=') +MINIMUM_NM_VERSION_CHECK = """ - networkmanager_version is version({minimum_nm_version}, '>=') """ EXTRA_RUN_CONDITION_PREFIX = " - " @@ -51,6 +50,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{{{ ansible_facts['distribution_major_version'] }}}}" + __network_is_rhel: "{{{{ ansible_facts['distribution'] == 'RedHat' }}}}" + __network_is_fedora: "{{{{ ansible_facts['distribution'] == 'Fedora' }}}}" + __network_is_centos: "{{{{ ansible_facts['distribution'] == 'CentOS' }}}}" + __network_is_os_family_rhel: "{{{{ ansible_facts['os_family'] == 'RedHat' }}}}" + __is_rh_distro: "{{{{ __network_is_rh_distro }}}}" {get_nm_version} # The test requires or should run with NetworkManager, therefore it cannot run @@ -58,24 +67,57 @@ {comment}- name: Import the playbook '{test_playbook}' import_playbook: {test_playbook} when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' {minimum_nm_version_check}{extra_run_condition}""" + +RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause +# This file was generated by ensure_provider_tests.py +--- +# yamllint disable rule:line-length +- name: Run playbook '{test_playbook}' with initscripts 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 'initscripts' + set_fact: + network_provider: initscripts + tags: + - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{{{ ansible_facts['distribution_major_version'] }}}}" + __network_is_rhel: "{{{{ ansible_facts['distribution'] == 'RedHat' }}}}" + __network_is_fedora: "{{{{ ansible_facts['distribution'] == 'Fedora' }}}}" + __network_is_centos: "{{{{ ansible_facts['distribution'] == 'CentOS' }}}}" + __network_is_os_family_rhel: "{{{{ ansible_facts['os_family'] == 'RedHat' }}}}" + __is_rh_distro: "{{{{ __network_is_rh_distro }}}}" +- name: Import the playbook '{test_playbook}' + import_playbook: {test_playbook} + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 +""" + + MINIMUM_VERSION = "minimum_version" EXTRA_RUN_CONDITION = "extra_run_condition" NM_ONLY_TESTS = { "playbooks/tests_802_1x_updated.yml": { EXTRA_RUN_CONDITION: ( - "(ansible_facts['distribution'] != 'RedHat' and\n" - " ansible_facts['distribution_major_version'] | int > 7) or\n" - " ansible_facts['distribution_major_version'] | int == 8" + "(not __network_is_rhel and\n" + " __network_distro_major_version | int > 7) or\n" + " __network_distro_major_version | int == 8" ), }, "playbooks/tests_802_1x.yml": { EXTRA_RUN_CONDITION: ( - "(ansible_facts['distribution'] != 'RedHat' and\n" - " ansible_facts['distribution_major_version'] | int > 7) or\n" - " ansible_facts['distribution_major_version'] | int == 8" + "(not __network_is_rhel and\n" + " __network_distro_major_version | int > 7) or\n" + " __network_distro_major_version | int == 8" ), }, "playbooks/tests_ignore_auto_dns.yml": {}, @@ -92,12 +134,12 @@ }, "playbooks/tests_provider.yml": { MINIMUM_VERSION: "'1.20.0'", - "comment": "# NetworKmanager 1.20.0 added support for forgetting profiles", + "comment": "# NetworkManager 1.20.0 added support for forgetting profiles", EXTRA_RUN_CONDITION: ( - "(ansible_facts['distribution'] == 'Fedora'\n" - " and ansible_facts['distribution_major_version'] | int < 41)\n" - " or ansible_facts['distribution'] not in ['RedHat', 'CentOS', 'Fedora']\n" - " or ansible_facts['distribution_major_version'] | int < 9" + "(__network_is_fedora and\n" + " __network_distro_major_version | int < 41)\n" + " or not __network_is_os_family_rhel\n" + " or __network_distro_major_version | int < 9" ), }, "playbooks/tests_eth_pci_address_match.yml": { @@ -105,7 +147,7 @@ "comment": "# NetworkManager 1.26.0 added support for match.path setting", }, "playbooks/tests_network_state.yml": { - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] | int > 7", + EXTRA_RUN_CONDITION: "__network_distro_major_version | int > 7", }, "playbooks/tests_reapply.yml": {}, "playbooks/tests_route_table.yml": {}, @@ -117,30 +159,30 @@ "playbooks/tests_routing_rules.yml": {}, # teaming support dropped in EL10 "playbooks/tests_team.yml": { - EXTRA_RUN_CONDITION: "ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or\n ansible_facts['distribution_major_version'] | int < 10", + EXTRA_RUN_CONDITION: "not __is_rh_distro or\n __network_distro_major_version | int < 10", }, "playbooks/tests_team_plugin_installation.yml": { - EXTRA_RUN_CONDITION: "ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or\n ansible_facts['distribution_major_version'] | int < 10", + EXTRA_RUN_CONDITION: "not __is_rh_distro or\n __network_distro_major_version | int < 10", }, # mac80211_hwsim (used for tests_wireless) only seems to be available # and working on RHEL/CentOS 7 "playbooks/tests_wireless.yml": { - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] == '7'", + EXTRA_RUN_CONDITION: "__network_distro_major_version == '7'", }, "playbooks/tests_wireless_and_network_restart.yml": {}, "playbooks/tests_wireless_plugin_installation.yml": {}, "playbooks/tests_wireless_wpa3_owe.yml": { "comment": "# OWE has not been supported by NetworkManager 1.18.8 on \ RHEL 7(dist-tag). Failed in setting up mock wifi on RHEL 8", - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] > '7' and \ -ansible_facts['distribution'] == 'CentOS' or\n ansible_facts['distribution_major_version'] > '32' \ -and ansible_facts['distribution'] == 'Fedora'", + EXTRA_RUN_CONDITION: "__network_distro_major_version | int > 7 and \ +__network_is_centos or\n __network_distro_major_version | int > 32 \ +and __network_is_fedora", }, "playbooks/tests_wireless_wpa3_sae.yml": { "comment": "# SAE has not been supported by NetworkManager 1.18.8 on \ RHEL 7. Failed in setting up mock wifi on RHEL 8", - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] != '7' and \ -ansible_facts['distribution'] != 'RedHat'", + EXTRA_RUN_CONDITION: "__network_distro_major_version != '7' and \ +not __network_is_rhel", }, } # NM_CONDITIONAL_TESTS is used to store the test playbooks which are demanding for NM @@ -168,27 +210,6 @@ "playbooks/tests_switch_provider.yml", ] -RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause -# This file was generated by ensure_provider_tests.py ---- -# yamllint disable rule:line-length -- name: Run playbook '{test_playbook}' with initscripts 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 'initscripts' - set_fact: - network_provider: initscripts - tags: - - always - -- name: Import the playbook '{test_playbook}' - import_playbook: {test_playbook} - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and\n \ -ansible_facts['distribution_major_version'] | int < 9) -""" - def create_nm_playbook(test_playbook): fileroot = os.path.splitext(os.path.basename(test_playbook))[0] diff --git a/tests/library/network_connections.py b/tests/library/network_connections.py new file mode 120000 index 000000000..c4bee42c0 --- /dev/null +++ b/tests/library/network_connections.py @@ -0,0 +1 @@ +../../library/network_connections.py \ No newline at end of file diff --git a/tests/playbooks/manual_test_ethtool_coalesce.yml b/tests/playbooks/manual_test_ethtool_coalesce.yml index 2b58626ae..a1cee7813 100644 --- a/tests/playbooks/manual_test_ethtool_coalesce.yml +++ b/tests/playbooks/manual_test_ethtool_coalesce.yml @@ -34,8 +34,7 @@ register: original_ethtool_coalesce changed_when: false - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -57,8 +56,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -91,8 +89,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -118,14 +115,13 @@ - "tests::cleanup" block: - name: Deactivate the connection and remove the connection profile - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'manage_test_interface.yml' include_tasks: tasks/manage_test_interface.yml vars: diff --git a/tests/playbooks/tests_802_1x.yml b/tests/playbooks/tests_802_1x.yml index 8f922aa9b..466f3d5fa 100644 --- a/tests/playbooks/tests_802_1x.yml +++ b/tests/playbooks/tests_802_1x.yml @@ -16,8 +16,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -48,8 +47,7 @@ command: ping -c1 203.0.113.1 changed_when: false - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -79,8 +77,7 @@ executable: /bin/bash changed_when: false - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -105,8 +102,7 @@ command: ping -c1 203.0.113.1 changed_when: false - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -121,8 +117,7 @@ - "tests::cleanup" block: - name: Deactivate the connection and remove the connection profile - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -131,7 +126,7 @@ - name: br1 persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'cleanup_802_1x_server.yml' include_tasks: tasks/cleanup_802_1x_server.yml - name: Remove test certificates diff --git a/tests/playbooks/tests_auto_gateway.yml b/tests/playbooks/tests_auto_gateway.yml index 28f595213..834c6b957 100644 --- a/tests/playbooks/tests_auto_gateway.yml +++ b/tests/playbooks/tests_auto_gateway.yml @@ -19,8 +19,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -68,8 +67,7 @@ debug: msg: "##################################################" - name: Import network role to remove interface - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -89,8 +87,7 @@ vars: state: present - name: Import network role to disable auto_gateway - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -134,8 +131,7 @@ debug: msg: "##################################################" - name: Import network role to remove interface again - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_bond.yml b/tests/playbooks/tests_bond.yml index 348207783..48cd72f4d 100644 --- a/tests/playbooks/tests_bond.yml +++ b/tests/playbooks/tests_bond.yml @@ -34,8 +34,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller @@ -98,8 +97,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ port2_profile }}" @@ -111,7 +109,7 @@ - name: "{{ controller_profile }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ controller_device }}' command: ip link del {{ controller_device }} failed_when: false diff --git a/tests/playbooks/tests_bond_cloned_mac.yml b/tests/playbooks/tests_bond_cloned_mac.yml index 511ff0e8d..4641ce381 100644 --- a/tests/playbooks/tests_bond_cloned_mac.yml +++ b/tests/playbooks/tests_bond_cloned_mac.yml @@ -25,8 +25,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller @@ -109,8 +108,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ port2_profile }}" @@ -122,7 +120,7 @@ - name: "{{ controller_profile }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ controller_device }}' command: ip link del {{ controller_device }} failed_when: false diff --git a/tests/playbooks/tests_bond_deprecated.yml b/tests/playbooks/tests_bond_deprecated.yml index 3c63b982c..ef2ae4db3 100644 --- a/tests/playbooks/tests_bond_deprecated.yml +++ b/tests/playbooks/tests_bond_deprecated.yml @@ -34,8 +34,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller @@ -109,8 +108,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ port2_profile }}" @@ -122,7 +120,7 @@ - name: "{{ controller_profile }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ controller_device }}' command: ip link del {{ controller_device }} failed_when: false diff --git a/tests/playbooks/tests_bond_removal.yml b/tests/playbooks/tests_bond_removal.yml index 3cf16c58c..e118f8ee0 100644 --- a/tests/playbooks/tests_bond_removal.yml +++ b/tests/playbooks/tests_bond_removal.yml @@ -34,8 +34,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller @@ -95,8 +94,7 @@ - name: Deactivate and remove the bond controller profile "{{ controller_profile }}" - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ controller_profile }}" @@ -162,8 +160,7 @@ when: network_provider == "initscripts" - name: Activate the bonding connection again - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller @@ -190,8 +187,7 @@ controller: "{{ controller_profile }}" - name: Deactivate and remove all the port profiles - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ port1_profile }}" @@ -238,14 +234,13 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ controller_profile }}" state: down persistent_state: absent - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ controller_device }}' command: ip link del {{ controller_device }} failed_when: false diff --git a/tests/playbooks/tests_bridge.yml b/tests/playbooks/tests_bridge.yml index 09f4c8a78..a9f63eaf2 100644 --- a/tests/playbooks/tests_bridge.yml +++ b/tests/playbooks/tests_bridge.yml @@ -12,8 +12,7 @@ include_tasks: tasks/assert_device_absent.yml - name: Add test bridge - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_bridge_cloned_mac.yml b/tests/playbooks/tests_bridge_cloned_mac.yml index 96ae93197..7bea51956 100644 --- a/tests/playbooks/tests_bridge_cloned_mac.yml +++ b/tests/playbooks/tests_bridge_cloned_mac.yml @@ -7,8 +7,7 @@ cloned_mac: "12:23:34:45:56:70" tasks: - name: Add test bridge - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_checkpoint_cleanup.yml b/tests/playbooks/tests_checkpoint_cleanup.yml index 0fea2e081..322aeebfa 100644 --- a/tests/playbooks/tests_checkpoint_cleanup.yml +++ b/tests/playbooks/tests_checkpoint_cleanup.yml @@ -18,9 +18,9 @@ include_tasks: tasks/show_interfaces.yml - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml - roles: - - linux-system-roles.network tasks: + - name: Run role with clear facts + include_tasks: tasks/run_role_with_clear_facts.yml - name: Test checkpoint cleanup block: # Workaround for https://bugzilla.redhat.com/show_bug.cgi?id=1832897 @@ -32,8 +32,7 @@ ternary('ansible.posix.rhel_rpm_ostree', omit) }}" # create test profile - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_provider: initscripts network_connections: diff --git a/tests/playbooks/tests_eth_dns_support.yml b/tests/playbooks/tests_eth_dns_support.yml index 5322370b4..71d4acf34 100644 --- a/tests/playbooks/tests_eth_dns_support.yml +++ b/tests/playbooks/tests_eth_dns_support.yml @@ -18,8 +18,7 @@ include_tasks: tasks/assert_device_present.yml - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_eth_pci_address_match.yml b/tests/playbooks/tests_eth_pci_address_match.yml index e58f97594..68a9f0d22 100644 --- a/tests/playbooks/tests_eth_pci_address_match.yml +++ b/tests/playbooks/tests_eth_pci_address_match.yml @@ -4,8 +4,7 @@ hosts: all tasks: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: pseudo-pci-test-only @@ -37,8 +36,7 @@ address - name: "Remove the PCI address from match path" - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: pseudo-pci-test-only @@ -71,13 +69,12 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: pseudo-pci-test-only persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Verify network state restored to default include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_ethernet.yml b/tests/playbooks/tests_ethernet.yml index e0b636e1b..cad08e31a 100644 --- a/tests/playbooks/tests_ethernet.yml +++ b/tests/playbooks/tests_ethernet.yml @@ -26,8 +26,7 @@ include_tasks: tasks/assert_device_present.yml - name: Test static interface up - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_ethtool_coalesce.yml b/tests/playbooks/tests_ethtool_coalesce.yml index d28899117..e3fb5a4a8 100644 --- a/tests/playbooks/tests_ethtool_coalesce.yml +++ b/tests/playbooks/tests_ethtool_coalesce.yml @@ -37,8 +37,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -78,8 +77,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -121,8 +119,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -163,13 +160,12 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent - failed_when: false + __sr_failed_when: false - name: Include the task 'manage_test_interface.yml' include_tasks: tasks/manage_test_interface.yml vars: diff --git a/tests/playbooks/tests_ethtool_features.yml b/tests/playbooks/tests_ethtool_features.yml index 3bdc3c4ee..61358b62f 100644 --- a/tests/playbooks/tests_ethtool_features.yml +++ b/tests/playbooks/tests_ethtool_features.yml @@ -41,8 +41,7 @@ register: original_ethtool_features changed_when: false - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -65,8 +64,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -105,8 +103,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -181,8 +178,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -208,14 +204,13 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'manage_test_interface.yml' include_tasks: tasks/manage_test_interface.yml vars: diff --git a/tests/playbooks/tests_ethtool_ring.yml b/tests/playbooks/tests_ethtool_ring.yml index fdcc263de..22f2c95b4 100644 --- a/tests/playbooks/tests_ethtool_ring.yml +++ b/tests/playbooks/tests_ethtool_ring.yml @@ -37,8 +37,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -78,8 +77,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -162,8 +160,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -204,13 +201,12 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent - failed_when: false + __sr_failed_when: false - name: Include the task 'manage_test_interface.yml' include_tasks: tasks/manage_test_interface.yml vars: diff --git a/tests/playbooks/tests_ignore_auto_dns.yml b/tests/playbooks/tests_ignore_auto_dns.yml index f191ce8b3..265418b25 100644 --- a/tests/playbooks/tests_ignore_auto_dns.yml +++ b/tests/playbooks/tests_ignore_auto_dns.yml @@ -21,8 +21,7 @@ block: - name: Configure an interface with ipv4_ignore_auto_dns disabled and ipv6_ignore_auto_dns enabled - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -64,8 +63,7 @@ - "tests::cleanup" block: - name: Bring down test devices and profiles - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_infiniband.yml b/tests/playbooks/tests_infiniband.yml index 65a85c93a..7b9be7499 100644 --- a/tests/playbooks/tests_infiniband.yml +++ b/tests/playbooks/tests_infiniband.yml @@ -14,8 +14,7 @@ debug: msg: "##################################################" - name: Setup the IP over the infiniband device - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -74,8 +73,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -84,7 +82,7 @@ - name: "{{ interface }}-10" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the virtual device command: ip link del {{ interface }}.000a failed_when: false diff --git a/tests/playbooks/tests_ipv6.yml b/tests/playbooks/tests_ipv6.yml index 1e653a7af..1ffbacc40 100644 --- a/tests/playbooks/tests_ipv6.yml +++ b/tests/playbooks/tests_ipv6.yml @@ -29,8 +29,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -94,8 +93,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_ipv6_disabled.yml b/tests/playbooks/tests_ipv6_disabled.yml index f8aea90f5..589b6a9ea 100644 --- a/tests/playbooks/tests_ipv6_disabled.yml +++ b/tests/playbooks/tests_ipv6_disabled.yml @@ -24,8 +24,7 @@ - name: Try configuration block: - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_ipv6_dns_search.yml b/tests/playbooks/tests_ipv6_dns_search.yml index 2f7c7f78b..f6bbb435d 100644 --- a/tests/playbooks/tests_ipv6_dns_search.yml +++ b/tests/playbooks/tests_ipv6_dns_search.yml @@ -6,8 +6,7 @@ block: - name: Configure the static IPv4 address and not configure the IPv6 address - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: br-example @@ -48,8 +47,7 @@ - name: Reconfigure the static IPv4 and IPv6 address, reconfigure DNS and DNS search setting for IPv4 and IPv6 - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: br-example @@ -82,8 +80,7 @@ - name: Reconfigure connection profile and only configure the static IPv6 address - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: br-example @@ -112,40 +109,37 @@ msg: DNS search setting for IPv6 is not configured when only the static IPv6 address is configured - - name: Reconfigure connection profile, disable both IPv4 and IPv6 - import_role: - name: linux-system-roles.network - vars: - network_connections: - - name: br-example - type: bridge - ip: - dhcp4: false - ipv6_disabled: true - dns_search: example.com - state: up - ignore_errors: true # noqa ignore-errors - changed_when: false - when: ansible_facts["distribution_major_version"] | int > 7 - - - name: Assert that reconfiguring network connection is failed - assert: - that: - - __network_connections_result.failed - msg: reconfiguring network connection is not failed - when: ansible_facts["distribution_major_version"] | int > 7 + - name: Check for errors when both IPv4 and IPv6 are disabled + when: __network_distro_major_version | int > 7 + block: + - name: Reconfigure connection profile, disable both IPv4 and IPv6 + include_tasks: tasks/run_role_with_clear_facts.yml + vars: + network_connections: + - name: br-example + type: bridge + ip: + dhcp4: false + ipv6_disabled: true + dns_search: example.com + state: up + rescue: + - name: Assert that reconfiguring network connection is failed + assert: + that: + - __network_connections_result.failed + msg: reconfiguring network connection is not failed - - name: Assert that configuring DNS search setting is not allowed when - both IPv4 and IPv6 are disabled - assert: - that: - - __network_connections_result.stderr is search("Setting - 'dns_search', 'dns_options' and 'dns_priority' are not allowed - when both IPv4 and IPv6 are disabled.") - msg: Reconfiguring network connection is not failed with the error - "Setting 'dns_search', 'dns_options', and 'dns_priority' are not - allowed when both IPv4 and IPv6 are disabled." - when: ansible_facts["distribution_major_version"] | int > 7 + - name: Assert that configuring DNS search setting is not allowed when + both IPv4 and IPv6 are disabled + assert: + that: + - __network_connections_result.stderr is search("Setting + 'dns_search', 'dns_options' and 'dns_priority' are not allowed + when both IPv4 and IPv6 are disabled.") + msg: Reconfiguring network connection is not failed with the error + "Setting 'dns_search', 'dns_options', and 'dns_priority' are not + allowed when both IPv4 and IPv6 are disabled." always: - name: Clean up the test device and the connection profile @@ -153,13 +147,12 @@ - "tests::cleanup" block: - name: Deactivate the connection and remove the connection profile - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: br-example persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Verify network state restored to default include_tasks: tasks/check_network_dns.yml diff --git a/tests/playbooks/tests_network_state.yml b/tests/playbooks/tests_network_state.yml index 5e6260fc0..c13e796a7 100644 --- a/tests/playbooks/tests_network_state.yml +++ b/tests/playbooks/tests_network_state.yml @@ -36,8 +36,7 @@ - name: Configure the IP addresses - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_state: interfaces: @@ -102,8 +101,7 @@ settings - name: Configure the route - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_state: routes: @@ -131,8 +129,7 @@ msg: the route configuration does not contain the specified route - name: Configure the DNS - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_state: dns-resolver: @@ -174,8 +171,7 @@ contain the specified DNS configuration - name: Purge the DNS - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_state: dns-resolver: diff --git a/tests/playbooks/tests_reapply.yml b/tests/playbooks/tests_reapply.yml index 97040551b..45a32bb80 100644 --- a/tests/playbooks/tests_reapply.yml +++ b/tests/playbooks/tests_reapply.yml @@ -18,15 +18,14 @@ include_tasks: tasks/show_interfaces.yml - name: Include the task 'assert_device_absent.yml' include_tasks: tasks/assert_device_absent.yml - roles: - - linux-system-roles.network tasks: + - name: Run role with clear facts + include_tasks: tasks/run_role_with_clear_facts.yml - name: Test reapply the connection block: # create test profile - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_route_device.yml b/tests/playbooks/tests_route_device.yml index 13a4d87e9..be6f16698 100644 --- a/tests/playbooks/tests_route_device.yml +++ b/tests/playbooks/tests_route_device.yml @@ -36,8 +36,7 @@ block: - name: Configure the IP addresses and the route with interface name specified - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface0 }}" @@ -111,8 +110,7 @@ changed_when: false - name: Configure the IP addresses and the route with only the MAC address specified - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface1 }}" @@ -157,8 +155,7 @@ - "tests::cleanup" block: - name: Bring down test devices and profiles - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface0 }}" diff --git a/tests/playbooks/tests_route_table.yml b/tests/playbooks/tests_route_table.yml index 4a7f1df2b..1febca072 100644 --- a/tests/playbooks/tests_route_table.yml +++ b/tests/playbooks/tests_route_table.yml @@ -19,8 +19,7 @@ - name: Configure connection profile and specify the numeric table in static routes - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -110,8 +109,7 @@ - name: Reconfigure connection profile and specify the named table in static routes - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_route_type.yml b/tests/playbooks/tests_route_type.yml index 22c24fe5b..272fc240d 100644 --- a/tests/playbooks/tests_route_type.yml +++ b/tests/playbooks/tests_route_type.yml @@ -19,8 +19,7 @@ - name: Configure connection profile and specify the route types in static routes - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -100,8 +99,7 @@ specified route" - name: Removing some routes - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_routing_rules.yml b/tests/playbooks/tests_routing_rules.yml index 7bb303497..b53105e6c 100644 --- a/tests/playbooks/tests_routing_rules.yml +++ b/tests/playbooks/tests_routing_rules.yml @@ -33,8 +33,7 @@ block: - name: Configure connection profile and specify the numeric table in static routes - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_switch_provider.yml b/tests/playbooks/tests_switch_provider.yml index 98404111c..98521dd54 100644 --- a/tests/playbooks/tests_switch_provider.yml +++ b/tests/playbooks/tests_switch_provider.yml @@ -10,8 +10,7 @@ tasks: - name: "Through the initscripts provider, create test bridge {{ interface }}" - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -40,8 +39,7 @@ - always - name: "Through the nm provider, create test bridge {{ interface }}" - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_vlan_mtu.yml b/tests/playbooks/tests_vlan_mtu.yml index ade0aa7b6..51838cb3a 100644 --- a/tests/playbooks/tests_vlan_mtu.yml +++ b/tests/playbooks/tests_vlan_mtu.yml @@ -20,8 +20,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -59,8 +58,7 @@ debug: msg: "##################################################" - name: Import network role to remove interfaces - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/playbooks/tests_wireless.yml b/tests/playbooks/tests_wireless.yml index fbcccc3b3..912a958b3 100644 --- a/tests/playbooks/tests_wireless.yml +++ b/tests/playbooks/tests_wireless.yml @@ -25,8 +25,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: @@ -43,8 +42,7 @@ key_mgmt: "wpa-psk" password: "p@55w0rD" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -54,8 +52,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: @@ -85,14 +82,13 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml - name: Verify network state restored to default diff --git a/tests/playbooks/tests_wireless_plugin_installation.yml b/tests/playbooks/tests_wireless_plugin_installation.yml index bd8e4df90..2a4371818 100644 --- a/tests/playbooks/tests_wireless_plugin_installation.yml +++ b/tests/playbooks/tests_wireless_plugin_installation.yml @@ -24,8 +24,7 @@ msg: "NetworkManager-wifi is not removed before wirelss configuration" - name: "Wireless configuration" - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: diff --git a/tests/playbooks/tests_wireless_wpa3_owe.yml b/tests/playbooks/tests_wireless_wpa3_owe.yml index 51400e426..40b111908 100644 --- a/tests/playbooks/tests_wireless_wpa3_owe.yml +++ b/tests/playbooks/tests_wireless_wpa3_owe.yml @@ -16,8 +16,7 @@ debug: msg: "##################################################" - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: @@ -50,14 +49,13 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml - name: Verify network state restored to default diff --git a/tests/playbooks/tests_wireless_wpa3_sae.yml b/tests/playbooks/tests_wireless_wpa3_sae.yml index ba3fb149c..09f954fee 100644 --- a/tests/playbooks/tests_wireless_wpa3_sae.yml +++ b/tests/playbooks/tests_wireless_wpa3_sae.yml @@ -12,8 +12,7 @@ - name: Test wireless connection with WPA3 Personal block: - name: "TEST: wireless connection with WPA3 Personal" - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: @@ -51,14 +50,13 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Include the task 'cleanup_mock_wifi.yml' include_tasks: tasks/cleanup_mock_wifi.yml - name: Verify network state restored to default diff --git a/tests/tasks/activate_profile.yml b/tests/tasks/activate_profile.yml index e3e75bdc3..318d81f20 100644 --- a/tests/tasks/activate_profile.yml +++ b/tests/tasks/activate_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/cleanup_bond_profile+device.yml b/tests/tasks/cleanup_bond_profile+device.yml index a6b666c5e..1b0f9263c 100644 --- a/tests/tasks/cleanup_bond_profile+device.yml +++ b/tests/tasks/cleanup_bond_profile+device.yml @@ -5,8 +5,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ port2_profile }}" @@ -18,7 +17,7 @@ - name: "{{ controller_profile }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ controller_device }}' command: ip link del {{ controller_device }} failed_when: false diff --git a/tests/tasks/cleanup_vlan_and_parent_profile+device.yml b/tests/tasks/cleanup_vlan_and_parent_profile+device.yml index be5bc9043..bd06b2f32 100644 --- a/tests/tasks/cleanup_vlan_and_parent_profile+device.yml +++ b/tests/tasks/cleanup_vlan_and_parent_profile+device.yml @@ -5,8 +5,7 @@ - "tests::cleanup" block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ profile }}" @@ -18,7 +17,7 @@ - name: "{{ vlan_profile2 }}" persistent_state: absent state: down - failed_when: false + __sr_failed_when: false - name: Delete the device '{{ interface }}' command: ip link del {{ interface }} failed_when: false diff --git a/tests/tasks/create_bond_port_match_by_mac.yml b/tests/tasks/create_bond_port_match_by_mac.yml index 5de8133e2..84defd986 100644 --- a/tests/tasks/create_bond_port_match_by_mac.yml +++ b/tests/tasks/create_bond_port_match_by_mac.yml @@ -13,8 +13,7 @@ debug: msg: "Retrieved MAC address for {{ interface }}: {{ mac }}" - name: Test matching the port device based on the perm_hwaddr - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ profile }}" diff --git a/tests/tasks/create_bond_profile.yml b/tests/tasks/create_bond_profile.yml index 3624ec0c2..d2896a1a2 100644 --- a/tests/tasks/create_bond_profile.yml +++ b/tests/tasks/create_bond_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller diff --git a/tests/tasks/create_bond_profile_reconfigure.yml b/tests/tasks/create_bond_profile_reconfigure.yml index 323c2d0ca..2eae9682a 100644 --- a/tests/tasks/create_bond_profile_reconfigure.yml +++ b/tests/tasks/create_bond_profile_reconfigure.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Reconfigure the bond options - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: # Create a bond controller diff --git a/tests/tasks/create_bridge_profile.yml b/tests/tasks/create_bridge_profile.yml index 4eb22481b..6bf2dd518 100644 --- a/tests/tasks/create_bridge_profile.yml +++ b/tests/tasks/create_bridge_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/create_bridge_profile_no_autoconnect.yml b/tests/tasks/create_bridge_profile_no_autoconnect.yml index f93ec5dba..e790daf10 100644 --- a/tests/tasks/create_bridge_profile_no_autoconnect.yml +++ b/tests/tasks/create_bridge_profile_no_autoconnect.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/create_dummy_profile.yml b/tests/tasks/create_dummy_profile.yml index 1e65ac605..88a2937f1 100644 --- a/tests/tasks/create_dummy_profile.yml +++ b/tests/tasks/create_dummy_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/create_mac_address_match.yml b/tests/tasks/create_mac_address_match.yml index 412127bb9..40916a519 100644 --- a/tests/tasks/create_mac_address_match.yml +++ b/tests/tasks/create_mac_address_match.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/create_team_profile.yml b/tests/tasks/create_team_profile.yml index 5d8ea72d8..0939d4327 100644 --- a/tests/tasks/create_team_profile.yml +++ b/tests/tasks/create_team_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_allow_restart: true network_connections: diff --git a/tests/tasks/create_wireless_profile_restart_network.yml b/tests/tasks/create_wireless_profile_restart_network.yml index 6e8505f6d..3d7c97a10 100644 --- a/tests/tasks/create_wireless_profile_restart_network.yml +++ b/tests/tasks/create_wireless_profile_restart_network.yml @@ -3,8 +3,7 @@ - name: Create wireless connection with rescue block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_allow_restart: '{{ wifi_restart_network }}' network_connections: diff --git a/tests/tasks/down_profile.yml b/tests/tasks/down_profile.yml index 25db269e2..d0140d660 100644 --- a/tests/tasks/down_profile.yml +++ b/tests/tasks/down_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Set down {{ profile }} - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ profile }}" diff --git a/tests/tasks/find+remove_profile.yml b/tests/tasks/find+remove_profile.yml index fae7a7ac6..8dbdf52b1 100644 --- a/tests/tasks/find+remove_profile.yml +++ b/tests/tasks/find+remove_profile.yml @@ -60,8 +60,7 @@ failed_when: connection_name is failed or connection_name.stdout | length == 0 - name: Bring down and delete the connection profile for '{{ interface }}' - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ connection_name.stdout }}" diff --git a/tests/tasks/provider/create_and_remove_with_initscripts.yml b/tests/tasks/provider/create_and_remove_with_initscripts.yml index 1bf3330dd..7c4113714 100644 --- a/tests/tasks/provider/create_and_remove_with_initscripts.yml +++ b/tests/tasks/provider/create_and_remove_with_initscripts.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: ../run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" @@ -14,8 +13,7 @@ address: 192.0.2.1/24 network_provider: initscripts - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: ../run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/provider/create_with_nm.yml b/tests/tasks/provider/create_with_nm.yml index aa98d053b..aab8e937b 100644 --- a/tests/tasks/provider/create_with_nm.yml +++ b/tests/tasks/provider/create_with_nm.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: ../run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/provider/default_with_nm.yml b/tests/tasks/provider/default_with_nm.yml index 349ae24f9..ac289ee10 100644 --- a/tests/tasks/provider/default_with_nm.yml +++ b/tests/tasks/provider/default_with_nm.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: ../run_role_with_clear_facts.yml vars: network_connections: [] network_provider: nm diff --git a/tests/tasks/remove+down_profile.yml b/tests/tasks/remove+down_profile.yml index 19cbfeea9..0fc227900 100644 --- a/tests/tasks/remove+down_profile.yml +++ b/tests/tasks/remove+down_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Include network role - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tasks/remove_profile.yml b/tests/tasks/remove_profile.yml index 1538e0156..ac0ee2683 100644 --- a/tests/tasks/remove_profile.yml +++ b/tests/tasks/remove_profile.yml @@ -1,8 +1,7 @@ # SPDX-License-Identifier: BSD-3-Clause --- - name: Remove {{ profile }} - include_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ profile }}" diff --git a/tests/tasks/run_role_with_clear_facts.yml b/tests/tasks/run_role_with_clear_facts.yml new file mode 100644 index 000000000..9df599cb8 --- /dev/null +++ b/tests/tasks/run_role_with_clear_facts.yml @@ -0,0 +1,39 @@ +--- +# Task file: save facts, clear_facts, run linux-system-roles.network, then restore facts. +# Include this with include_tasks or import_tasks; ensure tests/library is in module search path. +# Input: +# - __sr_tasks_from: tasks_from to run - same as tasks_from in include_role +# - __sr_public: export private vars from role - same as public in include_role +# - __sr_failed_when: set to false to ignore role errors - same as failed_when in include_role +# Output: +# - ansible_facts: merged saved ansible_facts with ansible_facts modified by the role, if any +- name: Clear facts + meta: clear_facts + +# note that you can use failed_when with import_role but not with include_role +# so this simulates the __sr_failed_when false case +# Q: Why do we need a separate task to run the role normally? Why not just +# run the role in the block and rethrow the error in the rescue block? +# A: Because you cannot rethrow the error in exactly the same way as the role does. +# It might be possible to exactly reconstruct ansible_failed_result but it's not worth the effort. +- name: Run the role with __sr_failed_when false + when: + - __sr_failed_when is defined + - not __sr_failed_when + block: + - name: Run the role + include_role: + name: linux-system-roles.network + tasks_from: "{{ __sr_tasks_from | default('main') }}" + public: "{{ __sr_public | default(false) }}" + rescue: + - name: Ignore the failure when __sr_failed_when is false + debug: + msg: Ignoring failure when __sr_failed_when is false + +- name: Run the role normally + include_role: + name: linux-system-roles.network + tasks_from: "{{ __sr_tasks_from | default('main') }}" + public: "{{ __sr_public | default(false) }}" + when: __sr_failed_when | d(true) diff --git a/tests/tasks/test_802.1x_capath.yml b/tests/tasks/test_802.1x_capath.yml index a8355282c..19aa5f28d 100644 --- a/tests/tasks/test_802.1x_capath.yml +++ b/tests/tasks/test_802.1x_capath.yml @@ -51,8 +51,7 @@ - name: Test configuring 802.1x authentication block: - name: Import network role - import_role: - name: linux-system-roles.network + include_tasks: run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface | default('802-1x-test') }}" diff --git a/tests/tests_802_1x_nm.yml b/tests/tests_802_1x_nm.yml index 36002de57..02cc2c9e7 100644 --- a/tests/tests_802_1x_nm.yml +++ b/tests/tests_802_1x_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,7 +30,7 @@ - name: Import the playbook 'playbooks/tests_802_1x.yml' import_playbook: playbooks/tests_802_1x.yml when: - - ansible_facts['distribution_major_version'] != '6' - - (ansible_facts['distribution'] != 'RedHat' and - ansible_facts['distribution_major_version'] | int > 7) or - ansible_facts['distribution_major_version'] | int == 8 + - __network_distro_major_version != '6' + - (not __network_is_rhel and + __network_distro_major_version | int > 7) or + __network_distro_major_version | int == 8 diff --git a/tests/tests_802_1x_updated_nm.yml b/tests/tests_802_1x_updated_nm.yml index b11a4be04..5f44dea7e 100644 --- a/tests/tests_802_1x_updated_nm.yml +++ b/tests/tests_802_1x_updated_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,7 +30,7 @@ - name: Import the playbook 'playbooks/tests_802_1x_updated.yml' import_playbook: playbooks/tests_802_1x_updated.yml when: - - ansible_facts['distribution_major_version'] != '6' - - (ansible_facts['distribution'] != 'RedHat' and - ansible_facts['distribution_major_version'] | int > 7) or - ansible_facts['distribution_major_version'] | int == 8 + - __network_distro_major_version != '6' + - (not __network_is_rhel and + __network_distro_major_version | int > 7) or + __network_distro_major_version | int == 8 diff --git a/tests/tests_auto_gateway_initscripts.yml b/tests/tests_auto_gateway_initscripts.yml index 37d74e3da..473c432ee 100644 --- a/tests/tests_auto_gateway_initscripts.yml +++ b/tests/tests_auto_gateway_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_auto_gateway.yml' import_playbook: playbooks/tests_auto_gateway.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_auto_gateway_nm.yml b/tests/tests_auto_gateway_nm.yml index 14ad4b16b..25f943e37 100644 --- a/tests/tests_auto_gateway_nm.yml +++ b/tests/tests_auto_gateway_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_auto_gateway.yml' import_playbook: playbooks/tests_auto_gateway.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_cloned_mac_initscripts.yml b/tests/tests_bond_cloned_mac_initscripts.yml index 45b9c3640..82d529530 100644 --- a/tests/tests_bond_cloned_mac_initscripts.yml +++ b/tests/tests_bond_cloned_mac_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bond_cloned_mac.yml' import_playbook: playbooks/tests_bond_cloned_mac.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bond_cloned_mac_nm.yml b/tests/tests_bond_cloned_mac_nm.yml index 57bf5e396..e822ae6fc 100644 --- a/tests/tests_bond_cloned_mac_nm.yml +++ b/tests/tests_bond_cloned_mac_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond_cloned_mac.yml' import_playbook: playbooks/tests_bond_cloned_mac.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_deprecated_initscripts.yml b/tests/tests_bond_deprecated_initscripts.yml index 2519d3876..606ac8121 100644 --- a/tests/tests_bond_deprecated_initscripts.yml +++ b/tests/tests_bond_deprecated_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bond_deprecated.yml' import_playbook: playbooks/tests_bond_deprecated.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bond_deprecated_nm.yml b/tests/tests_bond_deprecated_nm.yml index 0cd7148a1..8f413bf32 100644 --- a/tests/tests_bond_deprecated_nm.yml +++ b/tests/tests_bond_deprecated_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond_deprecated.yml' import_playbook: playbooks/tests_bond_deprecated.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_initscripts.yml b/tests/tests_bond_initscripts.yml index b2915e05b..a6f50822b 100644 --- a/tests/tests_bond_initscripts.yml +++ b/tests/tests_bond_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bond.yml' import_playbook: playbooks/tests_bond.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bond_nm.yml b/tests/tests_bond_nm.yml index 1541f79ce..7ecfcccb2 100644 --- a/tests/tests_bond_nm.yml +++ b/tests/tests_bond_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond.yml' import_playbook: playbooks/tests_bond.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_options_nm.yml b/tests/tests_bond_options_nm.yml index 95dbd202b..514f53bc9 100644 --- a/tests/tests_bond_options_nm.yml +++ b/tests/tests_bond_options_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond_options.yml' import_playbook: playbooks/tests_bond_options.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_port_match_by_mac_nm.yml b/tests/tests_bond_port_match_by_mac_nm.yml index fac5f733a..6f440d6bf 100644 --- a/tests/tests_bond_port_match_by_mac_nm.yml +++ b/tests/tests_bond_port_match_by_mac_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond_port_match_by_mac.yml' import_playbook: playbooks/tests_bond_port_match_by_mac.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bond_removal_initscripts.yml b/tests/tests_bond_removal_initscripts.yml index c565d7fdc..1b1a22295 100644 --- a/tests/tests_bond_removal_initscripts.yml +++ b/tests/tests_bond_removal_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bond_removal.yml' import_playbook: playbooks/tests_bond_removal.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bond_removal_nm.yml b/tests/tests_bond_removal_nm.yml index a8b9782cc..b8a4c07bb 100644 --- a/tests/tests_bond_removal_nm.yml +++ b/tests/tests_bond_removal_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bond_removal.yml' import_playbook: playbooks/tests_bond_removal.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bridge_cloned_mac_initscripts.yml b/tests/tests_bridge_cloned_mac_initscripts.yml index 71586e946..0b825ff21 100644 --- a/tests/tests_bridge_cloned_mac_initscripts.yml +++ b/tests/tests_bridge_cloned_mac_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bridge_cloned_mac.yml' import_playbook: playbooks/tests_bridge_cloned_mac.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bridge_cloned_mac_nm.yml b/tests/tests_bridge_cloned_mac_nm.yml index 575e21e74..33658db40 100644 --- a/tests/tests_bridge_cloned_mac_nm.yml +++ b/tests/tests_bridge_cloned_mac_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bridge_cloned_mac.yml' import_playbook: playbooks/tests_bridge_cloned_mac.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_bridge_initscripts.yml b/tests/tests_bridge_initscripts.yml index 1c0848303..99f4d65b7 100644 --- a/tests/tests_bridge_initscripts.yml +++ b/tests/tests_bridge_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_bridge.yml' import_playbook: playbooks/tests_bridge.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_bridge_nm.yml b/tests/tests_bridge_nm.yml index c44b4a3ac..c1085e48f 100644 --- a/tests/tests_bridge_nm.yml +++ b/tests/tests_bridge_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_bridge.yml' import_playbook: playbooks/tests_bridge.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_change_indication_on_repeat_run.yml b/tests/tests_change_indication_on_repeat_run.yml index 41f564a9c..945bcc081 100644 --- a/tests/tests_change_indication_on_repeat_run.yml +++ b/tests/tests_change_indication_on_repeat_run.yml @@ -37,15 +37,13 @@ - 192.0.2.2/24 block: - name: Include the network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml register: __network_connections_result - name: Assert change:true assert: that: __network_connections_result is changed - name: Include the network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml register: __network_connections_result - name: Assert change:false assert: @@ -61,15 +59,13 @@ auto6: "no" block: - name: Include the network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml register: __network_connections_result - name: Assert change:true assert: that: __network_connections_result is changed - name: Include the network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml register: __network_connections_result - name: Assert change:false assert: @@ -80,8 +76,7 @@ - "tests::cleanup" block: - name: Include the network role - include_role: - name: linux-system-roles.network + include_tasks: tasks/run_role_with_clear_facts.yml vars: network_connections: - name: "{{ interface }}" diff --git a/tests/tests_default.yml b/tests/tests_default.yml index 6577a513b..ccc3e60e2 100644 --- a/tests/tests_default.yml +++ b/tests/tests_default.yml @@ -2,13 +2,13 @@ --- - name: Test executing the role with default parameters hosts: all - gather_facts: false - roles: - - linux-system-roles.network tasks: - name: Include the task 'el_repo_setup.yml' include_tasks: tasks/el_repo_setup.yml + - name: Run role with clear facts + include_tasks: tasks/run_role_with_clear_facts.yml + # module_warning - see https://github.com/ansible/ansible/issues/85394 - name: Test warning and info logs assert: diff --git a/tests/tests_default_initscripts.yml b/tests/tests_default_initscripts.yml index dd525f814..751f64b10 100644 --- a/tests/tests_default_initscripts.yml +++ b/tests/tests_default_initscripts.yml @@ -8,8 +8,19 @@ - name: Set network provider to 'initscripts' set_fact: network_provider: initscripts + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + - name: Import the playbook 'tests_default.yml' import_playbook: tests_default.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __network_is_os_family_rhel + - __network_distro_major_version | int < 9 diff --git a/tests/tests_default_nm.yml b/tests/tests_default_nm.yml index 49933ab59..0f3679ab6 100644 --- a/tests/tests_default_nm.yml +++ b/tests/tests_default_nm.yml @@ -8,10 +8,22 @@ - name: Set network provider to 'nm' set_fact: network_provider: nm + tags: + - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + # The test should run with NetworkManager, therefore it cannot run on # RHEL/CentOS 6 - name: Import the playbook 'tests_default.yml' import_playbook: tests_default.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_dummy_nm.yml b/tests/tests_dummy_nm.yml index ff8c8ff79..3a17c7691 100644 --- a/tests/tests_dummy_nm.yml +++ b/tests/tests_dummy_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_dummy.yml' import_playbook: playbooks/tests_dummy.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_eth_dns_support_nm.yml b/tests/tests_eth_dns_support_nm.yml index 39057c34b..024dd149d 100644 --- a/tests/tests_eth_dns_support_nm.yml +++ b/tests/tests_eth_dns_support_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_eth_dns_support.yml' import_playbook: playbooks/tests_eth_dns_support.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_eth_pci_address_match_nm.yml b/tests/tests_eth_pci_address_match_nm.yml index ca0737a98..d3ded0c49 100644 --- a/tests/tests_eth_pci_address_match_nm.yml +++ b/tests/tests_eth_pci_address_match_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_eth_pci_address_match.yml' import_playbook: playbooks/tests_eth_pci_address_match.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.26.0', '>=') diff --git a/tests/tests_ethernet_initscripts.yml b/tests/tests_ethernet_initscripts.yml index 2ba274e11..9ddab9c93 100644 --- a/tests/tests_ethernet_initscripts.yml +++ b/tests/tests_ethernet_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_ethernet.yml' import_playbook: playbooks/tests_ethernet.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_ethernet_nm.yml b/tests/tests_ethernet_nm.yml index d2d286772..d181cb708 100644 --- a/tests/tests_ethernet_nm.yml +++ b/tests/tests_ethernet_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_ethernet.yml' import_playbook: playbooks/tests_ethernet.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_ethtool_coalesce_initscripts.yml b/tests/tests_ethtool_coalesce_initscripts.yml index a46d4cb7f..4c5d99a98 100644 --- a/tests/tests_ethtool_coalesce_initscripts.yml +++ b/tests/tests_ethtool_coalesce_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_ethtool_coalesce.yml' import_playbook: playbooks/tests_ethtool_coalesce.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_ethtool_coalesce_nm.yml b/tests/tests_ethtool_coalesce_nm.yml index d720c4e47..6fd088b13 100644 --- a/tests/tests_ethtool_coalesce_nm.yml +++ b/tests/tests_ethtool_coalesce_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_ethtool_coalesce.yml' import_playbook: playbooks/tests_ethtool_coalesce.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.25.1', '>=') diff --git a/tests/tests_ethtool_features_initscripts.yml b/tests/tests_ethtool_features_initscripts.yml index d499e58f4..8658f1fd9 100644 --- a/tests/tests_ethtool_features_initscripts.yml +++ b/tests/tests_ethtool_features_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_ethtool_features.yml' import_playbook: playbooks/tests_ethtool_features.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_ethtool_features_nm.yml b/tests/tests_ethtool_features_nm.yml index 8e65e8f10..161dbe374 100644 --- a/tests/tests_ethtool_features_nm.yml +++ b/tests/tests_ethtool_features_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_ethtool_features.yml' import_playbook: playbooks/tests_ethtool_features.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.20.0', '>=') diff --git a/tests/tests_ethtool_ring_initscripts.yml b/tests/tests_ethtool_ring_initscripts.yml index e55dbc483..d3e203a43 100644 --- a/tests/tests_ethtool_ring_initscripts.yml +++ b/tests/tests_ethtool_ring_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_ethtool_ring.yml' import_playbook: playbooks/tests_ethtool_ring.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_ethtool_ring_nm.yml b/tests/tests_ethtool_ring_nm.yml index 12508ae1c..f584b3986 100644 --- a/tests/tests_ethtool_ring_nm.yml +++ b/tests/tests_ethtool_ring_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_ethtool_ring.yml' import_playbook: playbooks/tests_ethtool_ring.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.25.2', '>=') diff --git a/tests/tests_ignore_auto_dns_nm.yml b/tests/tests_ignore_auto_dns_nm.yml index dd633d33d..3bdb57cee 100644 --- a/tests/tests_ignore_auto_dns_nm.yml +++ b/tests/tests_ignore_auto_dns_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_ignore_auto_dns.yml' import_playbook: playbooks/tests_ignore_auto_dns.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_infiniband_nm.yml b/tests/tests_infiniband_nm.yml index 8390eda98..5ef40568c 100644 --- a/tests/tests_infiniband_nm.yml +++ b/tests/tests_infiniband_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_infiniband.yml' import_playbook: playbooks/tests_infiniband.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_integration_pytest.yml b/tests/tests_integration_pytest.yml index d78c9203c..2e63f966a 100644 --- a/tests/tests_integration_pytest.yml +++ b/tests/tests_integration_pytest.yml @@ -5,10 +5,20 @@ tasks: - name: Include the task 'el_repo_setup.yml' include_tasks: tasks/el_repo_setup.yml + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + - name: Import the playbook 'playbooks/integration_pytest_python3.yml' import_playbook: playbooks/integration_pytest_python3.yml - when: (ansible_facts["distribution"] in ["CentOS", "RedHat"] and - ansible_facts["distribution_major_version"] == "8") or - (ansible_facts["distribution"] == "Fedora" and - ansible_facts["distribution_major_version"] | int < 39) + when: (__network_is_fedora and + __network_distro_major_version | int < 39) or + (__network_is_os_family_rhel and + __network_distro_major_version == "8") diff --git a/tests/tests_ipv6_disabled_nm.yml b/tests/tests_ipv6_disabled_nm.yml index 45e1a6196..dde950005 100644 --- a/tests/tests_ipv6_disabled_nm.yml +++ b/tests/tests_ipv6_disabled_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_ipv6_disabled.yml' import_playbook: playbooks/tests_ipv6_disabled.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_ipv6_dns_search_nm.yml b/tests/tests_ipv6_dns_search_nm.yml index 92eddeb87..c014f1ac0 100644 --- a/tests/tests_ipv6_dns_search_nm.yml +++ b/tests/tests_ipv6_dns_search_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_ipv6_dns_search.yml' import_playbook: playbooks/tests_ipv6_dns_search.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_ipv6_initscripts.yml b/tests/tests_ipv6_initscripts.yml index 1bcfe5861..b9e806470 100644 --- a/tests/tests_ipv6_initscripts.yml +++ b/tests/tests_ipv6_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_ipv6.yml' import_playbook: playbooks/tests_ipv6.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_ipv6_nm.yml b/tests/tests_ipv6_nm.yml index d07944c5a..9e3aa4c22 100644 --- a/tests/tests_ipv6_nm.yml +++ b/tests/tests_ipv6_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_ipv6.yml' import_playbook: playbooks/tests_ipv6.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_mac_address_match_nm.yml b/tests/tests_mac_address_match_nm.yml index 670d9d891..1a23debd8 100644 --- a/tests/tests_mac_address_match_nm.yml +++ b/tests/tests_mac_address_match_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_mac_address_match.yml' import_playbook: playbooks/tests_mac_address_match.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.18.0', '>=') diff --git a/tests/tests_network_state_nm.yml b/tests/tests_network_state_nm.yml index 4c9241bf0..dcb13beef 100644 --- a/tests/tests_network_state_nm.yml +++ b/tests/tests_network_state_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,5 +30,5 @@ - name: Import the playbook 'playbooks/tests_network_state.yml' import_playbook: playbooks/tests_network_state.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution_major_version'] | int > 7 + - __network_distro_major_version != '6' + - __network_distro_major_version | int > 7 diff --git a/tests/tests_provider_nm.yml b/tests/tests_provider_nm.yml index b67eb0ab3..4b43e3aea 100644 --- a/tests/tests_provider_nm.yml +++ b/tests/tests_provider_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -36,14 +46,13 @@ # The test requires or should run with NetworkManager, therefore it cannot run # on RHEL/CentOS 6 -# NetworKmanager 1.20.0 added support for forgetting profiles +# NetworkManager 1.20.0 added support for forgetting profiles - name: Import the playbook 'playbooks/tests_provider.yml' import_playbook: playbooks/tests_provider.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.20.0', '>=') - - (ansible_facts['distribution'] == 'Fedora' - and ansible_facts['distribution_major_version'] | int < 41) - or ansible_facts['distribution'] not in ['RedHat', 'CentOS', 'Fedora'] - or ansible_facts['distribution_major_version'] | int < 9 + - (__network_is_fedora and + __network_distro_major_version | int < 41) + or not __network_is_os_family_rhel + or __network_distro_major_version | int < 9 diff --git a/tests/tests_reapply_nm.yml b/tests/tests_reapply_nm.yml index 8c4205cba..aa78c6fe5 100644 --- a/tests/tests_reapply_nm.yml +++ b/tests/tests_reapply_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_reapply.yml' import_playbook: playbooks/tests_reapply.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_regression_nm.yml b/tests/tests_regression_nm.yml index 6b9ddac6b..732fe2771 100644 --- a/tests/tests_regression_nm.yml +++ b/tests/tests_regression_nm.yml @@ -23,6 +23,15 @@ set_fact: networkmanager_version: "{{ ansible_facts.packages['NetworkManager'][0]['version'] }}" + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" # workaround for: https://github.com/ansible/ansible/issues/27973 # There is no way in Ansible to abort a playbook hosts with specific OS @@ -32,10 +41,10 @@ - name: Import the playbook 'playbooks/tests_checkpoint_cleanup.yml' import_playbook: playbooks/tests_checkpoint_cleanup.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_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 + - not __network_is_os_family_rhel or + (__network_is_fedora and + __network_distro_major_version | int < 41) or + __network_distro_major_version | int < 9 diff --git a/tests/tests_route_device_initscripts.yml b/tests/tests_route_device_initscripts.yml index 4252f5fa4..94d8e25c3 100644 --- a/tests/tests_route_device_initscripts.yml +++ b/tests/tests_route_device_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_route_device.yml' import_playbook: playbooks/tests_route_device.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_route_device_nm.yml b/tests/tests_route_device_nm.yml index 688a6efb9..57f97818e 100644 --- a/tests/tests_route_device_nm.yml +++ b/tests/tests_route_device_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_route_device.yml' import_playbook: playbooks/tests_route_device.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_route_table_nm.yml b/tests/tests_route_table_nm.yml index 1249e9f07..6ccf5dc39 100644 --- a/tests/tests_route_table_nm.yml +++ b/tests/tests_route_table_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_route_table.yml' import_playbook: playbooks/tests_route_table.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_route_type_nm.yml b/tests/tests_route_type_nm.yml index 519d377fe..8ac573046 100644 --- a/tests/tests_route_type_nm.yml +++ b/tests/tests_route_type_nm.yml @@ -13,10 +13,20 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Install NetworkManager and get NetworkManager version when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' tags: - always block: @@ -40,6 +50,5 @@ - name: Import the playbook 'playbooks/tests_route_type.yml' import_playbook: playbooks/tests_route_type.yml when: - - ansible_facts['distribution_major_version'] != '6' - + - __network_distro_major_version != '6' - networkmanager_version is version('1.36.0', '>=') diff --git a/tests/tests_routing_rules_nm.yml b/tests/tests_routing_rules_nm.yml index a380abde0..cf12be102 100644 --- a/tests/tests_routing_rules_nm.yml +++ b/tests/tests_routing_rules_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_routing_rules.yml' import_playbook: playbooks/tests_routing_rules.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_states_initscripts.yml b/tests/tests_states_initscripts.yml index e03d48dd7..d86df0e15 100644 --- a/tests/tests_states_initscripts.yml +++ b/tests/tests_states_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_states.yml' import_playbook: playbooks/tests_states.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_states_nm.yml b/tests/tests_states_nm.yml index 2762baf6b..2f76d27c8 100644 --- a/tests/tests_states_nm.yml +++ b/tests/tests_states_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_states.yml' import_playbook: playbooks/tests_states.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_switch_provider.yml b/tests/tests_switch_provider.yml index bcdffadc1..03f73b57d 100644 --- a/tests/tests_switch_provider.yml +++ b/tests/tests_switch_provider.yml @@ -5,11 +5,21 @@ tasks: - name: Include the task 'el_repo_setup.yml' include_tasks: tasks/el_repo_setup.yml + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_switch_provider.yml' import_playbook: playbooks/tests_switch_provider.yml when: # The test requires NetworkManager and initscripts, therefore it can only # run on RHEL/CentOS 7, RHEL/CentOS 8, or Fedora - - ansible_facts['distribution'] in ['CentOS', 'RedHat'] and - ansible_facts['distribution_major_version'] in ['7', '8'] + - __is_rh_distro + - __network_distro_major_version in ['7', '8'] diff --git a/tests/tests_team_nm.yml b/tests/tests_team_nm.yml index 7db9bd2d3..642f0957c 100644 --- a/tests/tests_team_nm.yml +++ b/tests/tests_team_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,6 +30,6 @@ - name: Import the playbook 'playbooks/tests_team.yml' import_playbook: playbooks/tests_team.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or - ansible_facts['distribution_major_version'] | int < 10 + - __network_distro_major_version != '6' + - not __is_rh_distro or + __network_distro_major_version | int < 10 diff --git a/tests/tests_team_plugin_installation_nm.yml b/tests/tests_team_plugin_installation_nm.yml index eab233e7d..89485ad0c 100644 --- a/tests/tests_team_plugin_installation_nm.yml +++ b/tests/tests_team_plugin_installation_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,6 +30,6 @@ - name: Import the playbook 'playbooks/tests_team_plugin_installation.yml' import_playbook: playbooks/tests_team_plugin_installation.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or - ansible_facts['distribution_major_version'] | int < 10 + - __network_distro_major_version != '6' + - not __is_rh_distro or + __network_distro_major_version | int < 10 diff --git a/tests/tests_vlan_mtu_initscripts.yml b/tests/tests_vlan_mtu_initscripts.yml index bcd3c6d45..2ca02ed45 100644 --- a/tests/tests_vlan_mtu_initscripts.yml +++ b/tests/tests_vlan_mtu_initscripts.yml @@ -12,8 +12,18 @@ network_provider: initscripts tags: - always - + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" - name: Import the playbook 'playbooks/tests_vlan_mtu.yml' import_playbook: playbooks/tests_vlan_mtu.yml - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and - ansible_facts['distribution_major_version'] | int < 9) + when: + - __is_rh_distro + - __network_distro_major_version | int < 9 diff --git a/tests/tests_vlan_mtu_nm.yml b/tests/tests_vlan_mtu_nm.yml index 313cd3890..aed86cf3e 100644 --- a/tests/tests_vlan_mtu_nm.yml +++ b/tests/tests_vlan_mtu_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_vlan_mtu.yml' import_playbook: playbooks/tests_vlan_mtu.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_wireless_and_network_restart_nm.yml b/tests/tests_wireless_and_network_restart_nm.yml index c933e3952..0879d0ba5 100644 --- a/tests/tests_wireless_and_network_restart_nm.yml +++ b/tests/tests_wireless_and_network_restart_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_wireless_and_network_restart.yml' import_playbook: playbooks/tests_wireless_and_network_restart.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_wireless_nm.yml b/tests/tests_wireless_nm.yml index ae731e354..6a653df60 100644 --- a/tests/tests_wireless_nm.yml +++ b/tests/tests_wireless_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,5 +30,5 @@ - name: Import the playbook 'playbooks/tests_wireless.yml' import_playbook: playbooks/tests_wireless.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution_major_version'] == '7' + - __network_distro_major_version != '6' + - __network_distro_major_version == '7' diff --git a/tests/tests_wireless_plugin_installation_nm.yml b/tests/tests_wireless_plugin_installation_nm.yml index f03661001..042c64fdf 100644 --- a/tests/tests_wireless_plugin_installation_nm.yml +++ b/tests/tests_wireless_plugin_installation_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -20,4 +30,4 @@ - name: Import the playbook 'playbooks/tests_wireless_plugin_installation.yml' import_playbook: playbooks/tests_wireless_plugin_installation.yml when: - - ansible_facts['distribution_major_version'] != '6' + - __network_distro_major_version != '6' diff --git a/tests/tests_wireless_wpa3_owe_nm.yml b/tests/tests_wireless_wpa3_owe_nm.yml index 8ad4e87f9..88eff9f7a 100644 --- a/tests/tests_wireless_wpa3_owe_nm.yml +++ b/tests/tests_wireless_wpa3_owe_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -21,6 +31,6 @@ - name: Import the playbook 'playbooks/tests_wireless_wpa3_owe.yml' import_playbook: playbooks/tests_wireless_wpa3_owe.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution_major_version'] > '7' and ansible_facts['distribution'] == 'CentOS' or - ansible_facts['distribution_major_version'] > '32' and ansible_facts['distribution'] == 'Fedora' + - __network_distro_major_version != '6' + - __network_distro_major_version | int > 7 and __network_is_centos or + __network_distro_major_version | int > 32 and __network_is_fedora diff --git a/tests/tests_wireless_wpa3_sae_nm.yml b/tests/tests_wireless_wpa3_sae_nm.yml index 7981d9742..7600b1469 100644 --- a/tests/tests_wireless_wpa3_sae_nm.yml +++ b/tests/tests_wireless_wpa3_sae_nm.yml @@ -13,6 +13,16 @@ network_provider: nm tags: - always + - name: Include distro variables + include_vars: vars/rh_distros_vars.yml + - name: Set platform facts + set_fact: + __network_distro_major_version: "{{ ansible_facts['distribution_major_version'] }}" + __network_is_rhel: "{{ ansible_facts['distribution'] == 'RedHat' }}" + __network_is_fedora: "{{ ansible_facts['distribution'] == 'Fedora' }}" + __network_is_centos: "{{ ansible_facts['distribution'] == 'CentOS' }}" + __network_is_os_family_rhel: "{{ ansible_facts['os_family'] == 'RedHat' }}" + __is_rh_distro: "{{ __network_is_rh_distro }}" # The test requires or should run with NetworkManager, therefore it cannot run @@ -21,5 +31,5 @@ - name: Import the playbook 'playbooks/tests_wireless_wpa3_sae.yml' import_playbook: playbooks/tests_wireless_wpa3_sae.yml when: - - ansible_facts['distribution_major_version'] != '6' - - ansible_facts['distribution_major_version'] != '7' and ansible_facts['distribution'] != 'RedHat' + - __network_distro_major_version != '6' + - __network_distro_major_version != '7' and not __network_is_rhel diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index 2b0af8f16..32f22e6f2 100644 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Tests for network_connections Ansible module""" + # SPDX-License-Identifier: BSD-3-Clause import copy import itertools diff --git a/tests/unit/test_nm_provider.py b/tests/unit/test_nm_provider.py index 917575dae..70cb6cd50 100644 --- a/tests/unit/test_nm_provider.py +++ b/tests/unit/test_nm_provider.py @@ -1,5 +1,6 @@ #!/usr/bin/env python """Tests for network_connections Ansible module""" + # SPDX-License-Identifier: BSD-3-Clause import os