# SPDX-License-Identifier: BSD-3-Clause
---
- name: Play for testing wireless plugin installation
  hosts: all
  tasks:
    - name: Check if test can run on ostree systems
      include_tasks: tasks/ostree_systems_check.yml
      vars:
        package: NetworkManager-wifi

    - name: Remove the NetworkManager-wifi package
      package:
        name: "NetworkManager-wifi"
        state: absent

    - name: "Get the rpm package facts"
      package_facts:
        manager: "auto"

    - name: "Assert NetworkManager-wifi removed before wireless configuration"
      assert:
        that:
          - "'NetworkManager-wifi' not in ansible_facts.packages"
        msg: "NetworkManager-wifi is not removed before wirelss configuration"

    - name: "Wireless configuration"
      include_role:
        name: linux-system-roles.network
      vars:
        network_allow_restart: true
        network_connections:
          - name: wlan0
            type: wireless
            wireless:
              ssid: "My WPA2-PSK Network"
              key_mgmt: "wpa-psk"
              password: "p@55w0rD"

    - name: "Get the rpm package facts again"
      package_facts:
        manager: "auto"

    - name: "Assert NetworkManager-wifi installed after wireless configuration"
      assert:
        that:
          - "'NetworkManager-wifi' in ansible_facts.packages"
        msg: "NetworkManager-wifi is not installed after wireless configured"

    - name: Verify network state restored to default
      include_tasks: tasks/check_network_dns.yml
