systemd_link: rename interfaces

This commit is contained in:
jeltz 2023-03-27 13:09:58 +02:00
parent 71befe1b44
commit a2e181493d
Signed by: jeltz
GPG key ID: 800882B66C0C3326
5 changed files with 51 additions and 0 deletions

13
playbooks/systemd_link.yml Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env ansible-playbook
---
- hosts:
- edge-2.rtr.infra.auro.re
vars:
systemd_link__links:
viarezo0:
enabled: false
vlan123:
mac: 04:00:00:d8:d6:a2
roles:
- systemd_link
...

View file

@ -0,0 +1,3 @@
---
systemd_link__links: {}
...

View file

@ -0,0 +1,6 @@
---
- name: Restart systemd-udev-trigger
systemd:
name: systemd-udev-trigger.service
state: restarted
...

View file

@ -0,0 +1,22 @@
---
- name: Configure links
template:
src: link.j2
dest: "/etc/systemd/network/10-{{ item.key }}.link"
owner: root
group: root
mode: u=rw,g=r,o=r
when: "item.value.enabled | default(True)"
loop: "{{ systemd_link__links | dict2items }}"
notify:
- Restart systemd-udev-trigger
- name: Remove disabled links
file:
path: "/etc/systemd/network/10-{{ item.key }}.link"
state: absent
when: "not (item.value.enabled | default(True))"
loop: "{{ systemd_link__links | dict2items }}"
notify:
- Restart systemd-udev-trigger
...

View file

@ -0,0 +1,7 @@
{{ ansible_managed | comment }}
[Match]
MACAddress={{ item.value.mac }}
[Link]
Name={{ item.key }}