network/tests/playbooks/tests_wireless_wpa3_sae.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

65 lines
2.3 KiB
YAML

# SPDX-License-Identifier: BSD-3-Clause
---
- name: Play for testing wireless connection
hosts: all
vars:
interface: wlan0
tasks:
- name: "INIT: wireless tests"
include_tasks: tasks/setup_mock_wifi_wpa3_sae.yml
when: ansible_facts['distribution'] in ['CentOS', 'Fedora']
- name: Test wireless connection with WPA3 Personal
block:
- name: "TEST: wireless connection with WPA3 Personal"
import_role:
name: linux-system-roles.network
vars:
network_allow_restart: true
network_connections:
- name: "{{ interface }}"
# set `state: down` on RHEL 8 since we failed in setting up mock
# wifi on RHEL 8
state: "{{ 'down' if ansible_facts['distribution'] == 'RedHat' else 'up' }}"
type: wireless
ip:
address:
- 203.0.113.2/24
dhcp4: "no"
auto6: "no"
wireless:
ssid: "hostapd-sae"
key_mgmt: "sae"
password: "p@55w0rD"
- name: Verify wireless profile KEY_MGMT entry
shell: |
set -euxo pipefail
nmcli c show {{ interface }} | grep 802-11-wireless-security.key-mgmt
register: key_mgmt
ignore_errors: true
changed_when: false
- name: "Assert that WPA3 Personal is configured correctly"
assert:
that:
- "'sae' in key_mgmt.stdout"
msg: "WPA3 Personal is configured incorrectly"
always:
- name: Clean up the test device and the connection profile
tags:
- "tests::cleanup"
block:
- name: Import network role
import_role:
name: linux-system-roles.network
vars:
network_connections:
- name: "{{ interface }}"
persistent_state: absent
state: down
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
include_tasks: tasks/check_network_dns.yml