proxmox: fix network interface renaming

Use systemd .link files which are "relatively futureproof" according
to https://wiki.debian.org/NetworkInterfaceNames .
This commit is contained in:
Timotej Lazar 2025-08-13 12:03:28 +02:00
parent 59c1431f93
commit e499bbf570
3 changed files with 18 additions and 4 deletions

View file

@ -1,3 +1,7 @@
- name: update initramfs
command: update-initramfs -u -k all
when: "'handler' not in ansible_skip_tags"
- name: reboot - name: reboot
reboot: reboot:
when: "'handler' not in ansible_skip_tags" when: "'handler' not in ansible_skip_tags"

View file

@ -1,9 +1,14 @@
- name: Add rules to rename network interfaces - name: Add rules to rename network interfaces
template: template:
dest: /etc/udev/rules.d/10-network.rules dest: "/etc/systemd/network/10-{{ item.name }}.link"
src: 10-network.rules.j2 src: interface.link.j2
mode: 0644 mode: "0644"
notify: reboot 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 - name: Set up bridges
template: template:

View file

@ -0,0 +1,5 @@
[Match]
MACAddress={{ item.mac_address | lower }}
[Link]
Name={{ item.name }}