k3s-ansible/roles/node/tasks/network.yml

33 lines
890 B
YAML
Raw Permalink Normal View History

2024-12-23 14:53:44 +00:00
- name: Check if default interface is configured
ansible.builtin.set_fact:
interface_configured: "{{ interface_name in ansible_interfaces }}"
2024-11-23 21:46:13 +00:00
- 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"
2024-12-23 14:53:44 +00:00
notify:
- update initramfs
- reboot
when: not interface_configured
2024-11-23 21:46:13 +00:00
- 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"
2024-12-23 14:53:44 +00:00
when: not interface_configured
- name: Configure nameservers
ansible.builtin.template:
src: etc-resolv.conf.j2
dest: /etc/resolv.conf
mode: "0644"
2024-11-23 21:46:13 +00:00
- name: Enable systemd-networkd
ansible.builtin.systemd_service:
name: systemd-networkd
enabled: true
state: restarted