k3s-ansible/roles/node/tasks/network.yml
2024-12-23 15:53:44 +01:00

33 lines
890 B
YAML

- name: Check if default interface is configured
ansible.builtin.set_fact:
interface_configured: "{{ interface_name in ansible_interfaces }}"
- name: Configure default interface name
ansible.builtin.template:
src: etc-systemd-network-10-lan0.link.j2
dest: /etc/systemd/network/10-lan0.link
mode: "0644"
notify:
- update initramfs
- reboot
when: not interface_configured
- name: Configure network for default interface
ansible.builtin.template:
src: etc-systemd-network-20-lan0.network.j2
dest: /etc/systemd/network/20-lan0.network
mode: "0644"
when: not interface_configured
- name: Configure nameservers
ansible.builtin.template:
src: etc-resolv.conf.j2
dest: /etc/resolv.conf
mode: "0644"
- name: Enable systemd-networkd
ansible.builtin.systemd_service:
name: systemd-networkd
enabled: true
state: restarted