diff --git a/bundles/systemd-networkd/files/template-bond.netdev b/bundles/systemd-networkd/files/template-bond.netdev new file mode 100644 index 0000000..08b14c3 --- /dev/null +++ b/bundles/systemd-networkd/files/template-bond.netdev @@ -0,0 +1,6 @@ +[NetDev] +Name=${bond} +Kind=bond + +[Bond] +Mode=${mode} diff --git a/bundles/systemd-networkd/files/template-bond.network b/bundles/systemd-networkd/files/template-bond.network new file mode 100644 index 0000000..e7849fa --- /dev/null +++ b/bundles/systemd-networkd/files/template-bond.network @@ -0,0 +1,5 @@ +[Match] +Name=${' '.join(sorted(match))} + +[Network] +Bond=${bond} diff --git a/bundles/systemd-networkd/files/template-bridge.netdev b/bundles/systemd-networkd/files/template-bridge.netdev new file mode 100644 index 0000000..4fc400f --- /dev/null +++ b/bundles/systemd-networkd/files/template-bridge.netdev @@ -0,0 +1,3 @@ +[NetDev] +Name=${bridge} +Kind=bridge diff --git a/bundles/systemd-networkd/files/template-bridge.network b/bundles/systemd-networkd/files/template-bridge.network new file mode 100644 index 0000000..0487f79 --- /dev/null +++ b/bundles/systemd-networkd/files/template-bridge.network @@ -0,0 +1,5 @@ +[Match] +Name=${' '.join(sorted(match))} + +[Network] +Bridge=${bridge} diff --git a/bundles/systemd-networkd/files/template-dhcp.network b/bundles/systemd-networkd/files/template-iface-dhcp.network similarity index 100% rename from bundles/systemd-networkd/files/template-dhcp.network rename to bundles/systemd-networkd/files/template-iface-dhcp.network diff --git a/bundles/systemd-networkd/files/template.network b/bundles/systemd-networkd/files/template-iface-nodhcp.network similarity index 100% rename from bundles/systemd-networkd/files/template.network rename to bundles/systemd-networkd/files/template-iface-nodhcp.network diff --git a/bundles/systemd-networkd/items.py b/bundles/systemd-networkd/items.py index 52edaf8..0627b86 100644 --- a/bundles/systemd-networkd/items.py +++ b/bundles/systemd-networkd/items.py @@ -25,11 +25,11 @@ directories = { # config! for interface, config in node.metadata['interfaces'].items(): if config.get('dhcp', False): - template = 'template-dhcp.network' + template = 'template-iface-dhcp.network' else: - template = 'template.network' + template = 'template-iface-nodhcp.network' - files['/etc/systemd/network/10-{}.network'.format(interface)] = { + files['/etc/systemd/network/50-iface-{}.network'.format(interface)] = { 'source': template, 'content_type': 'mako', 'context': { @@ -44,6 +44,65 @@ for interface, config in node.metadata['interfaces'].items(): }, } +for bond, config in node.metadata.get('systemd-networkd', {}).get('bonds', {}).items(): + files['/etc/systemd/network/20-bond-{}.netdev'.format(bond)] = { + 'source': 'template-bond.netdev', + 'content_type': 'mako', + 'context': { + 'bond': bond, + 'mode': config.get('mode', '802.3ad'), + }, + 'needed_by': { + 'svc_systemd:systemd-networkd', + }, + 'triggers': { + 'svc_systemd:systemd-networkd:restart', + }, + } + files['/etc/systemd/network/21-bond-{}.network'.format(bond)] = { + 'source': 'template-bond.network', + 'content_type': 'mako', + 'context': { + 'bond': bond, + 'match': config['match'], + }, + 'needed_by': { + 'svc_systemd:systemd-networkd', + }, + 'triggers': { + 'svc_systemd:systemd-networkd:restart', + }, + } + +for brname, config in node.metadata.get('systemd-networkd', {}).get('bridges', {}).items(): + files['/etc/systemd/network/30-bridge-{}.netdev'.format(brname)] = { + 'source': 'template-bridge.netdev', + 'content_type': 'mako', + 'context': { + 'bridge': brname, + }, + 'needed_by': { + 'svc_systemd:systemd-networkd', + }, + 'triggers': { + 'svc_systemd:systemd-networkd:restart', + }, + } + files['/etc/systemd/network/31-bridge-{}.network'.format(brname)] = { + 'source': 'template-bridge.network', + 'content_type': 'mako', + 'context': { + 'bridge': brname, + 'match': config['match'], + }, + 'needed_by': { + 'svc_systemd:systemd-networkd', + }, + 'triggers': { + 'svc_systemd:systemd-networkd:restart', + }, + } + svc_systemd = { 'systemd-networkd': {}, }