Parcourir la source

set interface names with systemd network links

netifs
Parent
révision
e005b0a31d
2 fichiers modifiés avec 20 ajouts et 0 suppressions
  1. +13
    -0
      tasks/main.yml
  2. +7
    -0
      templates/systemd-network.link.j2

+ 13
- 0
tasks/main.yml Voir le fichier

@@ -40,3 +40,16 @@
with_items: "{{ _netifs }}"
when:
- ( root_target_dist | default('debian') ) == "debian"

- name: systemd network dir
file:
path: "{{ root_target_directory | default('') }}/etc/systemd/network"
state: directory

- name: systemd network interface names
template:
src: systemd-network.link.j2
dest: "{{ root_target_directory | default('') }}/etc/systemd/network/10-{{ item }}.link"
with_items: "{{ _netifs }}"
when:
- ( root_target_dist | default('debian') ) == "debian"

+ 7
- 0
templates/systemd-network.link.j2 Voir le fichier

@@ -0,0 +1,7 @@
{{ ansible_managed | comment }}
{% set netif = item %}
{% set dev = netifs[netif].device | default( 'enx' + netifs[netif].mac | regex_replace(':') ) %}
[Match]
MACAddress={{netifs[netif].mac}}
[Link]
Name={{dev}}

Chargement…
Annuler
Enregistrer