---
- name: networking | Install iwd package
  community.general.apk:
    name: iwd
    state: present
  when: not iwd_without_dbus

# NOTE: connmanctl can't scan wifi with eiwd so we need iw
# - iw dev <interface> scan | grep SSID
# - printf <passphrase> | iwd_passphrase <ssid> > /var/lib/iwd/<ssid>.psk
- name: networking | Install eiwd and iw packages
  community.general.apk:
    name: eiwd, iw
    state: present
  when: iwd_without_dbus

- name: networking | Copy iwd configuration
  copy:
    src: networking/iwd/main.conf
    dest: /etc/iwd/main.conf
    owner: root
    group: root
    mode: '644'

- name: networking | Start iwd service on runlevel 'boot'
  vars:
    iwd_service: '{{ iwd_without_dbus | ternary("eiwd", "iwd") }}'
  service:
    name: '{{ iwd_service }}'
    runlevel: default
    enabled: true
