## Make sure to use an initrd providing firmware:
##   wget https://cdimage.debian.org/cdimage/firmware/testing/current/firmware.cpio.gz
##   cat initrd.gz firmware.cpio.gz > initrd-fw.gz
---
- name: Configure WLAN for devices
  community.general.nmcli:
    conn_name: FVS-devices
    type: wifi
    ssid: FVS-devices
    ifname: "{{ ansible_interfaces | select('search', 'wl.+') | first }}"
    wifi_sec:
      key-mgmt: wpa-psk
      psk: "{{ wifipasswd }}"
    autoconnect: true
    state: present
  when: not run_in_installer|default(false)|bool

- name: Provide WLAN config during installation
  template:
    src: FVS-devices.nmconnection.j2
    dest: /etc/NetworkManager/system-connections/FVS-devices.nmconnection
    mode: '0600'
  when: run_in_installer|default(false)|bool
