systemd_link: rename interfaces
This commit is contained in:
parent
71befe1b44
commit
a2e181493d
5 changed files with 51 additions and 0 deletions
13
playbooks/systemd_link.yml
Executable file
13
playbooks/systemd_link.yml
Executable 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
|
||||
...
|
3
roles/systemd_link/defaults/main.yml
Normal file
3
roles/systemd_link/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
systemd_link__links: {}
|
||||
...
|
6
roles/systemd_link/handlers/main.yml
Normal file
6
roles/systemd_link/handlers/main.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
- name: Restart systemd-udev-trigger
|
||||
systemd:
|
||||
name: systemd-udev-trigger.service
|
||||
state: restarted
|
||||
...
|
22
roles/systemd_link/tasks/main.yml
Normal file
22
roles/systemd_link/tasks/main.yml
Normal 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
|
||||
...
|
7
roles/systemd_link/templates/link.j2
Normal file
7
roles/systemd_link/templates/link.j2
Normal file
|
@ -0,0 +1,7 @@
|
|||
{{ ansible_managed | comment }}
|
||||
|
||||
[Match]
|
||||
MACAddress={{ item.value.mac }}
|
||||
|
||||
[Link]
|
||||
Name={{ item.key }}
|
Loading…
Reference in a new issue