summaryrefslogtreecommitdiffstats
path: root/roles/network
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2026-02-26 20:17:35 +0100
committerAhmed Abdelhalim <[email protected]>2026-02-26 21:32:50 +0100
commit9b5fd8907d839f59b5a0de3b25056a64366b0b15 (patch)
tree997ff4fca43fcb1b256c69ffd276690a1cb4b58d /roles/network
parent8eb1bb1bdafa4fa539e179758769324dad6674b4 (diff)
Fix auto-starting iwd on boot
Diffstat (limited to 'roles/network')
-rw-r--r--roles/network/tasks/main.yml28
-rw-r--r--roles/network/templates/iwd-wifi.psk.j22
2 files changed, 30 insertions, 0 deletions
diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml
index 394ec688..a2358fe6 100644
--- a/roles/network/tasks/main.yml
+++ b/roles/network/tasks/main.yml
@@ -55,6 +55,16 @@
when: ansible_facts['is_chroot']
# noqa: command-instead-of-module module doesn't work inside chroot
+- name: "Compute hex-encoded SSID for iwd filename"
+ # noqa: risky-shell-pipe since this is used early before bash configuration
+ # it is the exception and needed to ensure that iwd is working on Mac machines
+ # that only work with broadcom-wl and iwd
+ ansible.builtin.shell:
+ cmd: "printf '%s' '{{ network_wifi_ssid }}' | xxd -p | tr -d '\\n'"
+ register: network_wifi_hex_ssid
+ changed_when: false
+ when: network_wifi_ssid != ""
+
- name: "Configure NetworkManager"
become: true
notify:
@@ -98,3 +108,21 @@
owner: "root"
group: "root"
when: network_wifi_ssid != ""
+
+ - name: "Ensure /var/lib/iwd directory exists"
+ ansible.builtin.file:
+ path: "/var/lib/iwd"
+ state: "directory"
+ mode: "0700"
+ owner: "root"
+ group: "root"
+ when: network_wifi_ssid != ""
+
+ - name: "Configure iwd known network for wifi auto-connect"
+ ansible.builtin.template:
+ src: "iwd-wifi.psk.j2"
+ dest: "/var/lib/iwd/={{ network_wifi_hex_ssid.stdout }}.psk"
+ mode: "0600"
+ owner: "root"
+ group: "root"
+ when: network_wifi_ssid != ""
diff --git a/roles/network/templates/iwd-wifi.psk.j2 b/roles/network/templates/iwd-wifi.psk.j2
new file mode 100644
index 00000000..df1fc2c3
--- /dev/null
+++ b/roles/network/templates/iwd-wifi.psk.j2
@@ -0,0 +1,2 @@
+[Security]
+Passphrase={{ network_wifi_pass }}