Browse Source

network: Generated systemd link files for really stable interface names on Debian Stretch.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
Maximilian Wilhelm 6 years ago
parent
commit
e6ae92914a
2 changed files with 24 additions and 0 deletions
  1. 15 0
      network/init.sls
  2. 9 0
      network/systemd-link.tmpl

+ 15 - 0
network/init.sls

@@ -44,6 +44,21 @@ vnstat:
     - template: jinja
     - source: salt://network/udev-rules.tmpl
 
+# Systemd link files?
+{% if grains['oscodename'] == 'stretch' %}
+  {% for iface, iface_config in salt['pillar.get']('nodes:' ~ grains['id'] ~ ':ifaces', {}).items ()|sort %}
+    {% if '_udev_mac' in iface_config %}
+/etc/systemd/network/42-{{ iface }}.link:
+  file.managed:
+    - source: salt://network/systemd-link.tmpl
+    - template: jinja
+      interface: {{ iface }}
+      mac: {{ iface_config.get ('_udev_mac') }}
+      desc: {{ iface_config.get ('desc', '') }}
+    {% endif %}
+  {% endfor %}
+{% endif %}
+
 
 # /etc/resolv.conf
 /etc/resolv.conf:

+ 9 - 0
network/systemd-link.tmpl

@@ -0,0 +1,9 @@
+#
+# {{ interface }} / {{ desc }}
+#
+
+[Match]
+MACAddress={{ mac }}
+
+[Link]
+Name={{ interface }}