Switch network management to systemd-networkd and iwd

This commit is contained in:
OpenCode Test
2026-01-01 13:29:22 -08:00
parent d38bc0c147
commit 0ae5220b5c
3 changed files with 56 additions and 18 deletions

View File

@@ -6,27 +6,34 @@
name: "{{ common_hostname }}"
tags: [ 'common', 'hostname' ]
- name: Configure WiFi connection '{{ common_wifi_connection_name }}'
become: true
ansible.builtin.command:
cmd: >
nmcli dev wifi connect "{{ common_wifi_ssid }}"
password "{{ common_wifi_password }}"
name "{{ common_wifi_connection_name }}"
args:
creates: "/etc/NetworkManager/system-connections/{{ common_wifi_connection_name }}.nmconnection"
ignore_errors: true
- name: Ensure systemd-networkd is enabled and running
ansible.builtin.service:
name: systemd-networkd
enabled: yes
state: started
tags: [ 'common', 'network' ]
- name: Ensure iwd is enabled and running
ansible.builtin.service:
name: iwd
enabled: yes
state: started
tags: [ 'common', 'network', 'wifi' ]
- name: Configure ethernet connection '{{ common_ethernet_con_name }}' with static IP, gateway, and DNS
become: true
ansible.builtin.command:
cmd: >
nmcli con add type ethernet ifname {{ common_ethernet_ifname }} con-name "{{ common_ethernet_con_name }}" ipv4.method manual ipv4.addresses {{ common_ethernet_ipv4_address }} ipv4.gateway {{ common_ethernet_ipv4_gateway }} ipv4.dns "{{ common_ethernet_ipv4_dns }}"
args:
creates: "/etc/NetworkManager/system-connections/{{ common_ethernet_con_name }}.nmconnection"
ignore_errors: true
- name: Deploy ethernet network configuration
ansible.builtin.copy:
src: files/20-ethernet.network
dest: /etc/systemd/network/20-ethernet.network
owner: root
group: root
mode: '0644'
notify: Restart systemd-networkd
tags: [ 'common', 'network', 'ethernet' ]
- name: Configure WiFi (requires manual interaction or pre-seeded iwd config)
debug:
msg: "WiFi configuration via Ansible for iwd is complex. Ensure /var/lib/iwd/ contains correct .psk files."
tags: [ 'common', 'network', 'wifi' ]
- name: Ensure user '{{ common_user_name }}' exists with specified password
ansible.builtin.user:
name: "{{ common_user_name }}"