|
12 | 12 | GET_NM_VERSION = """ |
13 | 13 | - name: Install NetworkManager and get NetworkManager version |
14 | 14 | when: |
15 | | - - ansible_facts['distribution_major_version'] != '6' |
| 15 | + - __network_distro_major_version != '6' |
16 | 16 | tags: |
17 | 17 | - always |
18 | 18 | block: |
|
30 | 30 | ansible_facts.packages['NetworkManager'][0]['version'] }}" |
31 | 31 | """ |
32 | 32 |
|
33 | | -MINIMUM_NM_VERSION_CHECK = """ |
34 | | - - networkmanager_version is version({minimum_nm_version}, '>=') |
| 33 | +MINIMUM_NM_VERSION_CHECK = """ - networkmanager_version is version({minimum_nm_version}, '>=') |
35 | 34 | """ |
36 | 35 |
|
37 | 36 | EXTRA_RUN_CONDITION_PREFIX = " - " |
|
51 | 50 | network_provider: nm |
52 | 51 | tags: |
53 | 52 | - always |
| 53 | + - name: Include distro variables |
| 54 | + include_vars: vars/rh_distros_vars.yml |
| 55 | + - name: Set platform facts |
| 56 | + set_fact: |
| 57 | + __network_distro_major_version: "{{{{ ansible_facts['distribution_major_version'] }}}}" |
| 58 | + __network_is_rhel: "{{{{ ansible_facts['distribution'] == 'RedHat' }}}}" |
| 59 | + __network_is_fedora: "{{{{ ansible_facts['distribution'] == 'Fedora' }}}}" |
| 60 | + __network_is_centos: "{{{{ ansible_facts['distribution'] == 'CentOS' }}}}" |
| 61 | + __network_is_os_family_rhel: "{{{{ ansible_facts['os_family'] == 'RedHat' }}}}" |
54 | 62 | {get_nm_version} |
55 | 63 |
|
56 | 64 | # The test requires or should run with NetworkManager, therefore it cannot run |
57 | 65 | # on RHEL/CentOS 6 |
58 | 66 | {comment}- name: Import the playbook '{test_playbook}' |
59 | 67 | import_playbook: {test_playbook} |
60 | 68 | when: |
61 | | - - ansible_facts['distribution_major_version'] != '6' |
| 69 | + - __network_distro_major_version != '6' |
62 | 70 | {minimum_nm_version_check}{extra_run_condition}""" |
63 | 71 |
|
| 72 | + |
| 73 | +RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause |
| 74 | +# This file was generated by ensure_provider_tests.py |
| 75 | +--- |
| 76 | +# yamllint disable rule:line-length |
| 77 | +- name: Run playbook '{test_playbook}' with initscripts as provider |
| 78 | + hosts: all |
| 79 | + tasks: |
| 80 | + - name: Include the task 'el_repo_setup.yml' |
| 81 | + include_tasks: tasks/el_repo_setup.yml |
| 82 | + - name: Set network provider to 'initscripts' |
| 83 | + set_fact: |
| 84 | + network_provider: initscripts |
| 85 | + tags: |
| 86 | + - always |
| 87 | + - name: Include distro variables |
| 88 | + include_vars: vars/rh_distros_vars.yml |
| 89 | + - name: Set platform facts |
| 90 | + set_fact: |
| 91 | + __network_distro_major_version: "{{{{ ansible_facts['distribution_major_version'] }}}}" |
| 92 | + __network_is_rhel: "{{{{ ansible_facts['distribution'] == 'RedHat' }}}}" |
| 93 | + __network_is_fedora: "{{{{ ansible_facts['distribution'] == 'Fedora' }}}}" |
| 94 | + __network_is_centos: "{{{{ ansible_facts['distribution'] == 'CentOS' }}}}" |
| 95 | + __network_is_os_family_rhel: "{{{{ ansible_facts['os_family'] == 'RedHat' }}}}" |
| 96 | +- name: Import the playbook '{test_playbook}' |
| 97 | + import_playbook: {test_playbook} |
| 98 | + when: |
| 99 | + - __network_is_rh_distro |
| 100 | + - __network_distro_major_version | int < 9 |
| 101 | +""" |
| 102 | + |
| 103 | + |
64 | 104 | MINIMUM_VERSION = "minimum_version" |
65 | 105 | EXTRA_RUN_CONDITION = "extra_run_condition" |
66 | 106 | NM_ONLY_TESTS = { |
67 | 107 | "playbooks/tests_802_1x_updated.yml": { |
68 | 108 | EXTRA_RUN_CONDITION: ( |
69 | | - "(ansible_facts['distribution'] != 'RedHat' and\n" |
70 | | - " ansible_facts['distribution_major_version'] | int > 7) or\n" |
71 | | - " ansible_facts['distribution_major_version'] | int == 8" |
| 109 | + "(not __network_is_rhel and\n" |
| 110 | + " __network_distro_major_version | int > 7) or\n" |
| 111 | + " __network_distro_major_version | int == 8" |
72 | 112 | ), |
73 | 113 | }, |
74 | 114 | "playbooks/tests_802_1x.yml": { |
75 | 115 | EXTRA_RUN_CONDITION: ( |
76 | | - "(ansible_facts['distribution'] != 'RedHat' and\n" |
77 | | - " ansible_facts['distribution_major_version'] | int > 7) or\n" |
78 | | - " ansible_facts['distribution_major_version'] | int == 8" |
| 116 | + "(not __network_is_rhel and\n" |
| 117 | + " __network_distro_major_version | int > 7) or\n" |
| 118 | + " __network_distro_major_version | int == 8" |
79 | 119 | ), |
80 | 120 | }, |
81 | 121 | "playbooks/tests_ignore_auto_dns.yml": {}, |
|
92 | 132 | }, |
93 | 133 | "playbooks/tests_provider.yml": { |
94 | 134 | MINIMUM_VERSION: "'1.20.0'", |
95 | | - "comment": "# NetworKmanager 1.20.0 added support for forgetting profiles", |
| 135 | + "comment": "# NetworkManager 1.20.0 added support for forgetting profiles", |
96 | 136 | EXTRA_RUN_CONDITION: ( |
97 | | - "(ansible_facts['distribution'] == 'Fedora'\n" |
98 | | - " and ansible_facts['distribution_major_version'] | int < 41)\n" |
99 | | - " or ansible_facts['distribution'] not in ['RedHat', 'CentOS', 'Fedora']\n" |
100 | | - " or ansible_facts['distribution_major_version'] | int < 9" |
| 137 | + "(__network_is_fedora and\n" |
| 138 | + " __network_distro_major_version | int < 41)\n" |
| 139 | + " or not __network_is_os_family_rhel\n" |
| 140 | + " or __network_distro_major_version | int < 9" |
101 | 141 | ), |
102 | 142 | }, |
103 | 143 | "playbooks/tests_eth_pci_address_match.yml": { |
104 | 144 | MINIMUM_VERSION: "'1.26.0'", |
105 | 145 | "comment": "# NetworkManager 1.26.0 added support for match.path setting", |
106 | 146 | }, |
107 | 147 | "playbooks/tests_network_state.yml": { |
108 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] | int > 7", |
| 148 | + EXTRA_RUN_CONDITION: "__network_distro_major_version | int > 7", |
109 | 149 | }, |
110 | 150 | "playbooks/tests_reapply.yml": {}, |
111 | 151 | "playbooks/tests_route_table.yml": {}, |
|
117 | 157 | "playbooks/tests_routing_rules.yml": {}, |
118 | 158 | # teaming support dropped in EL10 |
119 | 159 | "playbooks/tests_team.yml": { |
120 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or\n ansible_facts['distribution_major_version'] | int < 10", |
| 160 | + EXTRA_RUN_CONDITION: "not __network_is_rh_distro or\n __network_distro_major_version | int < 10", |
121 | 161 | }, |
122 | 162 | "playbooks/tests_team_plugin_installation.yml": { |
123 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution'] not in ['RedHat', 'CentOS'] or\n ansible_facts['distribution_major_version'] | int < 10", |
| 163 | + EXTRA_RUN_CONDITION: "not __network_is_rh_distro or\n __network_distro_major_version | int < 10", |
124 | 164 | }, |
125 | 165 | # mac80211_hwsim (used for tests_wireless) only seems to be available |
126 | 166 | # and working on RHEL/CentOS 7 |
127 | 167 | "playbooks/tests_wireless.yml": { |
128 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] == '7'", |
| 168 | + EXTRA_RUN_CONDITION: "__network_distro_major_version == '7'", |
129 | 169 | }, |
130 | 170 | "playbooks/tests_wireless_and_network_restart.yml": {}, |
131 | 171 | "playbooks/tests_wireless_plugin_installation.yml": {}, |
132 | 172 | "playbooks/tests_wireless_wpa3_owe.yml": { |
133 | 173 | "comment": "# OWE has not been supported by NetworkManager 1.18.8 on \ |
134 | 174 | RHEL 7(dist-tag). Failed in setting up mock wifi on RHEL 8", |
135 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] > '7' and \ |
136 | | -ansible_facts['distribution'] == 'CentOS' or\n ansible_facts['distribution_major_version'] > '32' \ |
137 | | -and ansible_facts['distribution'] == 'Fedora'", |
| 175 | + EXTRA_RUN_CONDITION: "__network_distro_major_version | int > 7 and \ |
| 176 | +__network_is_centos or\n __network_distro_major_version | int > 32 \ |
| 177 | +and __network_is_fedora", |
138 | 178 | }, |
139 | 179 | "playbooks/tests_wireless_wpa3_sae.yml": { |
140 | 180 | "comment": "# SAE has not been supported by NetworkManager 1.18.8 on \ |
141 | 181 | RHEL 7. Failed in setting up mock wifi on RHEL 8", |
142 | | - EXTRA_RUN_CONDITION: "ansible_facts['distribution_major_version'] != '7' and \ |
143 | | -ansible_facts['distribution'] != 'RedHat'", |
| 182 | + EXTRA_RUN_CONDITION: "__network_distro_major_version != '7' and \ |
| 183 | +not __network_is_rhel", |
144 | 184 | }, |
145 | 185 | } |
146 | 186 | # NM_CONDITIONAL_TESTS is used to store the test playbooks which are demanding for NM |
|
168 | 208 | "playbooks/tests_switch_provider.yml", |
169 | 209 | ] |
170 | 210 |
|
171 | | -RUN_PLAYBOOK_WITH_INITSCRIPTS = """# SPDX-License-Identifier: BSD-3-Clause |
172 | | -# This file was generated by ensure_provider_tests.py |
173 | | ---- |
174 | | -# yamllint disable rule:line-length |
175 | | -- name: Run playbook '{test_playbook}' with initscripts as provider |
176 | | - hosts: all |
177 | | - tasks: |
178 | | - - name: Include the task 'el_repo_setup.yml' |
179 | | - include_tasks: tasks/el_repo_setup.yml |
180 | | - - name: Set network provider to 'initscripts' |
181 | | - set_fact: |
182 | | - network_provider: initscripts |
183 | | - tags: |
184 | | - - always |
185 | | -
|
186 | | -- name: Import the playbook '{test_playbook}' |
187 | | - import_playbook: {test_playbook} |
188 | | - when: (ansible_facts['distribution'] in ['CentOS','RedHat'] and\n \ |
189 | | -ansible_facts['distribution_major_version'] | int < 9) |
190 | | -""" |
191 | | - |
192 | | - |
193 | 211 | def create_nm_playbook(test_playbook): |
194 | 212 | fileroot = os.path.splitext(os.path.basename(test_playbook))[0] |
195 | 213 | nm_testfile = fileroot + "_nm.yml" |
|
0 commit comments