This commit is contained in:
mwiegand 2021-06-28 23:03:05 +02:00
parent 42958f7834
commit d067f98c1b
6 changed files with 27 additions and 38 deletions

View file

@ -1,8 +1,8 @@
defaults = {
'network': {
'external': {
'gateway4': '172.31.1.1',
'gateway6': 'fe80::1',
},
},
}
# defaults = {
# 'network': {
# 'external': {
# 'gateway4': '172.31.1.1',
# 'gateway6': 'fe80::1',
# },
# },
# }

View file

@ -29,37 +29,18 @@ def systemd_networkd(metadata):
f'Address#ipv{i}': {
'Address': network[f'ipv{i}'],
},
f'Route#ipv{i}': {
'Gateway': network[f'gateway{i}'],
'GatewayOnlink': 'yes',
}
})
if f'gateway{i}' in network:
units[type].update({
f'Route#ipv{i}': {
'Gateway': network[f'gateway{i}'],
'GatewayOnlink': 'yes',
}
})
return {
'systemd-networkd': {
'networks': units,
}
}
@metadata_reactor.provides(
'network/gateway4',
'network/gateway6',
)
def guess_gateway(metadata):
networks = {}
for type, network in metadata.get('network').items():
if not network.get('gateway4', None):
if ip_interface(network['ipv4']).network.prefixlen == 32:
networks[type] = {
'gateway4': str(ip_interface(network['ipv4']).network[0]),
}
else:
networks[type] = {
'gateway4': str(ip_interface(network['ipv4']).network[1]),
}
return {
'network': networks,
}

View file

@ -16,6 +16,7 @@
'internal': {
'interface': 'enp1s0',
'ipv4': '10.0.0.5/24',
'gateway4': '10.0.0.1',
},
},
'zfs': {

View file

@ -17,6 +17,7 @@
'internal': {
'interface': 'enp1s0f0',
'ipv4': '10.0.0.2/24',
'gateway4': '10.0.0.1',
},
},
'gitea': {

View file

@ -49,6 +49,8 @@
'interface': 'eth0',
'ipv4': '162.55.188.157/32',
'ipv6': '2a01:4f8:1c1c:4121::2/64',
'gateway4': '172.31.1.1',
'gateway6': 'fe80::1',
}
},
'nginx': {
@ -107,9 +109,13 @@
'10.0.0.0/24',
'10.0.2.0/24',
'10.0.9.0/24',
]
],
},
'netcup.secondary': {
'route': [
'46.38.240.0/22',
],
},
'netcup.secondary': {},
},
},
'zfs': {

View file

@ -15,7 +15,7 @@
'gateway4': '46.38.240.1',
'ipv6': '2a03:4000:7:534::2/64',
'gateway6': 'fe80::1',
}
},
},
'wireguard': {
'my_ip': '172.19.136.3/22',