bundle/systemd-networkd #4
4 changed files with 59 additions and 0 deletions
3
bundles/systemd-networkd/files/interfaces
Normal file
3
bundles/systemd-networkd/files/interfaces
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
auto lo
|
||||||
|
iface lo inet loopback
|
||||||
|
iface lo inet6 loopback
|
33
bundles/systemd-networkd/files/template.network
Normal file
33
bundles/systemd-networkd/files/template.network
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
[Match]
|
||||||
|
Name=${interface}
|
||||||
|
|
||||||
|
[Network]
|
||||||
|
% if config.get('dhcp', False):
|
||||||
|
DHCP=yes
|
||||||
|
IPv6AcceptRA=yes
|
||||||
|
UseHostname=no
|
||||||
|
% else:
|
||||||
|
DHCP=no
|
||||||
|
IPv6AcceptRA=no
|
||||||
|
% endif
|
||||||
|
|
||||||
|
% for addr in sorted(config.get('ip_addresses', set())):
|
||||||
|
Address=${addr}
|
||||||
|
% endfor
|
||||||
|
|
||||||
|
% if config.get('ip4_masquerade_outgoing', False):
|
||||||
|
IPMasquerade=yes
|
||||||
|
IPForward=ipv4
|
||||||
|
%endif
|
||||||
|
|
||||||
|
% if 'ip6_gateway' in config:
|
||||||
|
[Route]
|
||||||
|
Gateway=${config['ip6_gateway']}
|
||||||
|
GatewayOnLink=yes
|
||||||
|
% endif
|
||||||
|
|
||||||
|
% if 'ip4_gateway' in config:
|
||||||
|
[Route]
|
||||||
|
Gateway=${config['ip4_gateway']}
|
||||||
|
GatewayOnLink=yes
|
||||||
|
% endif
|
22
bundles/systemd-networkd/items.py
Normal file
22
bundles/systemd-networkd/items.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
assert node.has_bundle('systemd')
|
||||||
|
|
||||||
|
files = {
|
||||||
|
'/etc/network/interfaces': {},
|
||||||
|
}
|
||||||
|
|
||||||
|
for interface, config in node.metadata.get('interfaces', {}).items():
|
||||||
|
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
||||||
|
'source': 'template.network',
|
||||||
|
'content_type': 'mako',
|
||||||
|
'context': {
|
||||||
|
'interface': interface,
|
||||||
|
'config': config,
|
||||||
|
},
|
||||||
|
'triggers': {
|
||||||
|
'svc_systemd:systemd-networkd:restart',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
svc_systemd = {
|
||||||
|
'systemd-networkd': {},
|
||||||
|
}
|
|
@ -9,6 +9,7 @@ groups['all'] = {
|
||||||
'postfix',
|
'postfix',
|
||||||
'sudo',
|
'sudo',
|
||||||
'systemd',
|
'systemd',
|
||||||
|
'systemd-networkd',
|
||||||
'users',
|
'users',
|
||||||
},
|
},
|
||||||
'metadata': {
|
'metadata': {
|
||||||
|
|
Loading…
Reference in a new issue