---
- hosts: wireless
  name: Disable APT services
  become: True
  gather_facts: False

  pre_tasks:
  - name: Gather min only
    ansible.builtin.setup:
      gather_subset:
        - "!all"

  tasks:
    - import_tasks: ../tasks/disable_apt_services.yml
      tags: apt_services

- name: Install packetfence development packages
  hosts: wireless
  become: True

  collections:
    - debops.debops
    - debops.roles01
    - debops.roles02
    - debops.roles03

  pre_tasks:
    - name: Gather min only
      ansible.builtin.setup:
        gather_subset:
          - "!all"

    # PPA repositories are removed each day and cause issues when refreshing cache
    - name: Clean previous ppa source file if present
      file:
        path: '/etc/apt/sources.list.d/packetfence-ppa.list'
        state: absent

    - name: Get packages installed
      package_facts:
        manager: 'apt'

    # to ensure wireless nodes always run tests with packetfence-test
    # installed from packetfence-ppa and not from a previous pipeline
    # where wireless nodes were provisioned
    - name: Uninstall packetfence-test if already installed
      apt:
        name: 'packetfence-test'
        state: 'absent'
      when: "'packetfence-test' in ansible_facts.packages"

  roles:
    - role: apt_preferences

    - role: inverse_inc.gitlab_buildpkg_tools
      tags: ci

- name: Configure Wireless Linux
  hosts: wireless
  become: true
  gather_facts: False
  
  collections:
    - inverse_inc.wireless

  pre_tasks:
  - name: Gather min only
    ansible.builtin.setup:
      gather_subset:
        - "!all"

  roles:
    - role: mac80211hwsim
    - role: hostapd
    - role: wpasupplicant
