Rework systemd-networkd role.

This commit is contained in:
Andreas B. Mundt 2022-04-02 10:14:11 +02:00 committed by Andreas B. Mundt
parent f9e8560f7b
commit 37c767ff0c
6 changed files with 40 additions and 44 deletions

View file

@ -1,5 +1,5 @@
[Match]
Name=en*
Name=e*
[Network]
DHCP=yes

View file

@ -0,0 +1,14 @@
- name: restart and enable systemd-networkd
systemd:
name: systemd-networkd
enabled: yes
state: restarted
daemon_reload: yes
listen: "start and enable systemd-networkd"
- name: start and enable systemd-resolved
systemd:
name: systemd-resolved
enabled: yes
state: started
listen: "start and enable systemd-resolved"

View file

@ -0,0 +1,25 @@
- name: move /etc/network/interfaces away
command:
cmd: mv /etc/network/interfaces /etc/network/interfaces_orig
creates: /etc/network/interfaces_orig
- name: switch to systemd-networkd
copy:
src: all-eth.network
dest: /etc/systemd/network/all-eth.network
notify: "start and enable systemd-networkd"
#- name: install static configuration for networkd
# template:
# src: 20-static.network.j2
# dest: /etc/systemd/network/20-static.network
# notify: "enable systemd-networkd"
- name: enable local stub resolver
file:
src: /run/systemd/resolve/stub-resolv.conf
dest: /etc/resolv.conf
state: link
follow: False
force: yes
notify: "start and enable systemd-resolved"

View file

@ -1,15 +0,0 @@
- name: enable systemd-networkd
systemd:
name: systemd-networkd
enabled: yes
state: restarted
daemon_reload: yes
listen: "start and enable systemd-networkd"
- name: use systemd-resolved
file:
src: /run/systemd/resolve/stub-resolv.conf
dest: /etc/resolv.conf
state: link
force: Yes
listen: "use systemd-resolved"

View file

@ -1,28 +0,0 @@
- name: check if /etc/network/interfaces is still there
stat: path=/etc/network/interfaces
register: interfaces
- name: move /etc/network/interfaces away
command: mv /etc/network/interfaces /etc/network/interfaces_disabled
when: interfaces.stat.exists
- name: install dynamic configuration for networkd
copy:
src: 10-dhcp.network
dest: /etc/systemd/network/10-dhcp.network
notify: "start and enable systemd-networkd"
#- name: install static configuration for networkd
# template:
# src: 20-static.network.j2
# dest: /etc/systemd/network/20-static.network
# notify: "enable systemd-networkd"
- name: enable systemd-resolved
systemd:
name: systemd-resolved
enabled: yes
state: started
notify: "use systemd-resolved"
- meta: flush_handlers