diff options
Diffstat (limited to 'roles/network')
| -rw-r--r-- | roles/network/tasks/main.yml | 28 | ||||
| -rw-r--r-- | roles/network/templates/iwd-wifi.psk.j2 | 2 |
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 }} |
