Merge pull request 'bundle/systemd-networkd' (#4) from interface-configuration into main
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
Reviewed-on: https://git.kunsmann.eu/kunsi/bundlewrap/pulls/4
This commit is contained in:
commit
5ffaa9b1c8
13 changed files with 125 additions and 28 deletions
14
bundles/systemd-networkd/files/template-dhcp.network
Normal file
14
bundles/systemd-networkd/files/template-dhcp.network
Normal file
|
@ -0,0 +1,14 @@
|
|||
<%
|
||||
from ipaddress import ip_network
|
||||
%>\
|
||||
[Match]
|
||||
Name=${interface}
|
||||
|
||||
[Network]
|
||||
DHCP=yes
|
||||
IPv6AcceptRA=yes
|
||||
UseHostname=no
|
||||
|
||||
% if config.get('forwarding', False):
|
||||
IPForward=yes
|
||||
%endif
|
38
bundles/systemd-networkd/files/template.network
Normal file
38
bundles/systemd-networkd/files/template.network
Normal file
|
@ -0,0 +1,38 @@
|
|||
<%
|
||||
from ipaddress import ip_network
|
||||
%>\
|
||||
[Match]
|
||||
Name=${interface}
|
||||
|
||||
% for addr in sorted(config.get('ips', set())):
|
||||
[Address]
|
||||
<%
|
||||
if '/' in addr:
|
||||
ip, prefix = addr.split('/')
|
||||
else:
|
||||
ip = addr
|
||||
prefix = '32'
|
||||
%>\
|
||||
Address=${ip}/${prefix}
|
||||
|
||||
% endfor
|
||||
|
||||
% if 'gateway4' in config:
|
||||
[Route]
|
||||
Gateway=${config['gateway4']}
|
||||
GatewayOnLink=yes
|
||||
% endif
|
||||
|
||||
% if 'gateway6' in config:
|
||||
[Route]
|
||||
Gateway=${config['gateway6']}
|
||||
GatewayOnLink=yes
|
||||
% endif
|
||||
|
||||
[Network]
|
||||
DHCP=no
|
||||
IPv6AcceptRA=no
|
||||
|
||||
% if config.get('forwarding', False):
|
||||
IPForward=yes
|
||||
%endif
|
40
bundles/systemd-networkd/items.py
Normal file
40
bundles/systemd-networkd/items.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
assert node.has_bundle('systemd')
|
||||
|
||||
files = {
|
||||
'/etc/network/interfaces': {
|
||||
'delete': True,
|
||||
},
|
||||
}
|
||||
|
||||
directories = {
|
||||
'/etc/systemd/network': {
|
||||
'purge': True,
|
||||
},
|
||||
}
|
||||
|
||||
# Don't use .get() here. We might end up with a node without a network
|
||||
# config!
|
||||
for interface, config in node.metadata['interfaces'].items():
|
||||
if config.get('dhcp', False):
|
||||
template = 'template-dhcp.network'
|
||||
else:
|
||||
template = 'template.network'
|
||||
|
||||
files['/etc/systemd/network/10-{}.network'.format(interface)] = {
|
||||
'source': template,
|
||||
'content_type': 'mako',
|
||||
'context': {
|
||||
'interface': interface,
|
||||
'config': config,
|
||||
},
|
||||
'needed_by': {
|
||||
'svc_systemd:systemd-networkd',
|
||||
},
|
||||
'triggers': {
|
||||
'svc_systemd:systemd-networkd:restart',
|
||||
},
|
||||
}
|
||||
|
||||
svc_systemd = {
|
||||
'systemd-networkd': {},
|
||||
}
|
|
@ -9,6 +9,7 @@ groups['all'] = {
|
|||
'postfix',
|
||||
'sudo',
|
||||
'systemd',
|
||||
'systemd-networkd',
|
||||
'users',
|
||||
},
|
||||
'metadata': {
|
||||
|
|
|
@ -20,9 +20,10 @@ def resolve_identifier(repo, identifier):
|
|||
found_ips = set()
|
||||
for node in nodes:
|
||||
for interface, config in node.metadata.get('interfaces', {}).items():
|
||||
for ip in config.get('ipv4', set()):
|
||||
found_ips.add(ip_address(ip))
|
||||
for ip in config.get('ipv4', set()):
|
||||
for ip in config.get('ips', set()):
|
||||
if '/' in ip:
|
||||
found_ips.add(ip_address(ip.split('/')[0]))
|
||||
else:
|
||||
found_ips.add(ip_address(ip))
|
||||
|
||||
if node.metadata.get('external_ipv4', None):
|
||||
|
|
|
@ -13,8 +13,8 @@ nodes['gce.bind01'] = {
|
|||
},
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ens4': {
|
||||
'ips': {
|
||||
'10.156.0.4',
|
||||
},
|
||||
'gateway4': '10.156.0.1',
|
||||
|
|
|
@ -9,8 +9,8 @@ nodes['gce.dns02'] = {
|
|||
},
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ens4': {
|
||||
'ips': {
|
||||
'10.132.0.2',
|
||||
},
|
||||
'gateway4': '10.132.0.1',
|
||||
|
|
|
@ -9,8 +9,8 @@ nodes['gce.dns03'] = {
|
|||
},
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ens4': {
|
||||
'ips': {
|
||||
'10.166.0.2',
|
||||
},
|
||||
'gateway4': '10.166.0.1',
|
||||
|
|
|
@ -10,11 +10,9 @@ nodes['htz-cloud.luther'] = {
|
|||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ips': {
|
||||
'195.201.136.20',
|
||||
},
|
||||
'ipv6': {
|
||||
'2a01:4f8:c2c:fc3b::1',
|
||||
'2a01:4f8:c2c:fc3b::1/64',
|
||||
},
|
||||
'gateway4': '172.31.1.1',
|
||||
'gateway6': 'fe80::1',
|
||||
|
|
|
@ -6,11 +6,9 @@ nodes['htz-cloud.pirmasens'] = {
|
|||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ips': {
|
||||
'195.201.90.143',
|
||||
},
|
||||
'ipv6': {
|
||||
'2a01:4f8:1c1c:2acf::1',
|
||||
'2a01:4f8:1c1c:2acf::1/64',
|
||||
},
|
||||
'gateway4': '172.31.1.1',
|
||||
'gateway6': 'fe80::1',
|
||||
|
|
|
@ -11,11 +11,9 @@ nodes['htz-cloud.sewfile'] = {
|
|||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ipv4': {
|
||||
'ips': {
|
||||
'116.203.205.248',
|
||||
},
|
||||
'ipv6': {
|
||||
'2a01:4f8:c0c:c71b::1',
|
||||
'2a01:4f8:c0c:c71b::1/64',
|
||||
},
|
||||
'gateway4': '172.31.1.1',
|
||||
'gateway6': 'fe80::1',
|
||||
|
|
|
@ -24,12 +24,10 @@ nodes['htz.ex42-1048908'] = {
|
|||
'metadata': {
|
||||
'interfaces': {
|
||||
'enp0s31f6': {
|
||||
'ipv4': {
|
||||
'94.130.52.224',
|
||||
},
|
||||
'ipv6': {
|
||||
'2a01:4f8:10b:2a5f::02',
|
||||
'2a01:4f8:10b:2a5f::1337',
|
||||
'ips': {
|
||||
'94.130.52.224/26',
|
||||
'2a01:4f8:10b:2a5f::02/64',
|
||||
'2a01:4f8:10b:2a5f::1337/64',
|
||||
},
|
||||
'gateway4': '94.130.52.193',
|
||||
'gateway6': 'fe80::1',
|
||||
|
|
|
@ -13,6 +13,17 @@ nodes['rx300'] = {
|
|||
},
|
||||
'groups': set(),
|
||||
'metadata': {
|
||||
'interfaces': {
|
||||
'eth0': {
|
||||
'ips': {
|
||||
'172.19.138.26/24',
|
||||
},
|
||||
'gateway4': '172.19.138.1',
|
||||
},
|
||||
'eth1': {
|
||||
'dhcp': True,
|
||||
},
|
||||
},
|
||||
'zfs': {
|
||||
'module_options': {
|
||||
'zfs_arc_max_mb': 16384, # 16GB
|
||||
|
|
Loading…
Reference in a new issue