From ef84b3f8894446a52d49ff2a9037d87d7717c4dc Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 10 Apr 2021 12:22:08 +0200 Subject: [PATCH] Revert "bundles/systemd-networkd: no need for a specific order in /etc/systemd/network/" This reverts commit b679f568ebd0a77fe4cf3f064465f36c6dbd32e0. Documentation says order is irrelevant, but it is not. If we do not use ordering, vlan interfaces are defined before the parent interfaces, which leads to systemd-networkd not applying config for the parent interfaces. --- bundles/systemd-networkd/items.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/bundles/systemd-networkd/items.py b/bundles/systemd-networkd/items.py index f5f54cb..42f7832 100644 --- a/bundles/systemd-networkd/items.py +++ b/bundles/systemd-networkd/items.py @@ -41,7 +41,7 @@ for interface, config in node.metadata['interfaces'].items(): if '.' in interface: vlan_id = int(interface.split('.')[1]) vlan_hex = '%02x' % (vlan_id % 255) - files[f'/etc/systemd/network/{interface}.netdev'] = { + files['/etc/systemd/network/60-iface-{}.netdev'.format(interface)] = { 'source': 'template-iface-vlan.netdev', 'content_type': 'mako', 'context': { @@ -56,9 +56,12 @@ for interface, config in node.metadata['interfaces'].items(): 'svc_systemd:systemd-networkd:restart', }, } + weight = 61 + else: + weight = 50 if not config.get('ignore', False): - files[f'/etc/systemd/network/{interface}.network'] = { + files['/etc/systemd/network/{}-iface-{}.network'.format(weight, interface)] = { 'source': template, 'content_type': 'mako', 'context': { @@ -74,7 +77,7 @@ for interface, config in node.metadata['interfaces'].items(): } for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items(): - files[f'/etc/systemd/network/{bond}.netdev'] = { + files['/etc/systemd/network/20-bond-{}.netdev'.format(bond)] = { 'source': 'template-bond.netdev', 'content_type': 'mako', 'context': { @@ -89,7 +92,7 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items(): 'svc_systemd:systemd-networkd:restart', }, } - files[f'/etc/systemd/network/{bond}.network'] = { + files['/etc/systemd/network/21-bond-{}.network'.format(bond)] = { 'source': 'template-bond.network', 'content_type': 'mako', 'context': { @@ -106,7 +109,7 @@ for bond, config in node.metadata.get('systemd-networkd/bonds', {}).items(): } for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items(): - files[f'/etc/systemd/network/{brname}.netdev'] = { + files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = { 'source': 'template-bridge.netdev', 'content_type': 'mako', 'context': { @@ -119,7 +122,7 @@ for brname, config in node.metadata.get('systemd-networkd/bridges', {}).items(): 'svc_systemd:systemd-networkd:restart', }, } - files[f'/etc/systemd/network/{brname}.network'] = { + files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = { 'source': 'template-bridge.network', 'content_type': 'mako', 'context': {