From e499bbf5701081984c3f987aca9f022c249cf4e3 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Wed, 13 Aug 2025 12:03:28 +0200 Subject: [PATCH] proxmox: fix network interface renaming Use systemd .link files which are "relatively futureproof" according to https://wiki.debian.org/NetworkInterfaceNames . --- roles/proxmox/handlers/main.yml | 4 ++++ roles/proxmox/tasks/network.yml | 13 +++++++++---- templates/interface.link.j2 | 5 +++++ 3 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 templates/interface.link.j2 diff --git a/roles/proxmox/handlers/main.yml b/roles/proxmox/handlers/main.yml index a48f969..8665671 100644 --- a/roles/proxmox/handlers/main.yml +++ b/roles/proxmox/handlers/main.yml @@ -1,3 +1,7 @@ +- name: update initramfs + command: update-initramfs -u -k all + when: "'handler' not in ansible_skip_tags" + - name: reboot reboot: when: "'handler' not in ansible_skip_tags" diff --git a/roles/proxmox/tasks/network.yml b/roles/proxmox/tasks/network.yml index 0a1c2ac..b85c520 100644 --- a/roles/proxmox/tasks/network.yml +++ b/roles/proxmox/tasks/network.yml @@ -1,9 +1,14 @@ - name: Add rules to rename network interfaces template: - dest: /etc/udev/rules.d/10-network.rules - src: 10-network.rules.j2 - mode: 0644 - notify: reboot + dest: "/etc/systemd/network/10-{{ item.name }}.link" + src: interface.link.j2 + mode: "0644" + loop: "{{ interfaces | selectattr('mac_address') }}" + loop_control: + label: "{{ item.name }}" + notify: + - update initramfs # recommended by https://pve.proxmox.com/wiki/Network_Configuration + - reboot - name: Set up bridges template: diff --git a/templates/interface.link.j2 b/templates/interface.link.j2 new file mode 100644 index 0000000..9d58da8 --- /dev/null +++ b/templates/interface.link.j2 @@ -0,0 +1,5 @@ +[Match] +MACAddress={{ item.mac_address | lower }} + +[Link] +Name={{ item.name }}