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

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

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

79 lines
2.7 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
- name: Install packages required to set up mock wifi network
package:
name:
- NetworkManager
- wpa_supplicant
state: present
use: "{{ (__network_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
register: __install_status
until: __install_status is success
retries: 6
delay: 10
- name: Check if can test on CentOS and setup if possible
when: ansible_facts['distribution'] == 'CentOS'
block:
# It is currently too difficult to install the required kernel
# if using rpm ostree - so just skip this test
- name: >-
This is an rpm-ostree system. This test cannot be run on such a system.
The test wants to install the hostapd package from copr, and install
the mac80211_hwsim kernel module. These operations are currently not
supported on rpm-ostree systems.
meta: end_host
when: __network_is_ostree | d(false)
# yamllint disable rule:line-length
# Even though hostapd can be installed via EPEL, Opportunistic Wireless Encryption
# (OWE) has not been enabled by default. To warrant the test support on RHEL(dist-tag),
# we setup hostapd copr repo to enable OWE option.
- name: Install hostapd and mac80211_hwsim kernel module in CentOS
shell: |
dnf -y copr enable liangwen12year/hostapd-owe
dnf -y install hostapd
release=$(uname -r)
tmp="${release/-//}"
tmp="${tmp/.x//x}"
dnf -y install https://kojihub.stream.centos.org/kojifiles/packages/kernel/$tmp/kernel-core-$release.rpm
dnf -y install https://kojihub.stream.centos.org/kojifiles/packages/kernel/$tmp/kernel-modules-$release.rpm
dnf -y install https://kojihub.stream.centos.org/kojifiles/packages/kernel/$tmp/kernel-modules-internal-$release.rpm
changed_when: false
# yamllint enable rule:line-length
- name: Install hostapd in Fedora
shell: |
dnf -y copr enable liangwen12year/hostapd-owe
dnf -y install hostapd
when:
- ansible_facts['distribution'] == 'Fedora'
changed_when: false
- name: Install mac80211_hwsim kernel modules in Fedora
shell: |
dnf -y install koji
koji download-build --arch=$(uname -m) kernel-modules-internal-$(uname -r)
dnf -y install kernel-modules*.rpm
when:
- ansible_facts['distribution'] == 'Fedora'
changed_when: false
- name: Create hostapd config
copy:
content: |
interface=wlan1
ssid=hostapd-owe
hw_mode=g
channel=6
wpa=2
wpa_key_mgmt=OWE
rsn_pairwise=CCMP
ieee80211w=2
nas_identifier=ap.example.com
dest: /etc/hostapd/wireless.conf
mode: "0644"
- name: Include the task 'start_mock_wifi.yml'
include_tasks: tasks/start_mock_wifi.yml