auto-generate full wireguard mesh between all nodes in libs.s2s.WG_AUTOGEN_NODES

This commit is contained in:
Franzi 2023-09-23 15:06:16 +02:00
parent e9f3268e15
commit 07de570175
Signed by: kunsi
GPG key ID: 12E3D2136B818350
4 changed files with 28 additions and 13 deletions

View file

@ -36,11 +36,37 @@ if node.has_bundle('telegraf'):
} }
@metadata_reactor.provides(
'wireguard/peers',
)
def peers_auto_full_mesh(metadata):
peers = {}
for rnode in repo.libs.s2s.WG_AUTOGEN_NODES:
if rnode is None or rnode == node.name:
continue
try:
rnode = repo.get_node(rnode)
except NoSuchNode:
continue
if rnode.dummy:
continue
peers[rnode.name] = {}
return {
'wireguard': {
'peers': peers,
},
}
@metadata_reactor.provides( @metadata_reactor.provides(
'wireguard/peers', 'wireguard/peers',
) )
def peer_psks_and_iface_names(metadata): def peer_psks(metadata):
peers = {} peers = {}
for peer_name in metadata.get('wireguard/peers', {}): for peer_name in metadata.get('wireguard/peers', {}):

View file

@ -1,5 +1,5 @@
nodes['home.router'] = { nodes['home.router'] = {
'hostname': '172.19.138.1', 'hostname': 'router-remote',
'bundles': { 'bundles': {
'bird', 'bird',
'kea-dhcp-server', 'kea-dhcp-server',
@ -162,10 +162,6 @@ nodes['home.router'] = {
'wireguard': { 'wireguard': {
'external_hostname': 'franzi-home.kunbox.net', # Set via DynDNS 'external_hostname': 'franzi-home.kunbox.net', # Set via DynDNS
'snat_ip': '172.19.138.1', 'snat_ip': '172.19.138.1',
'peers': {
'ovh.wireguard': {},
'icinga2': {},
},
}, },
}, },
} }

View file

@ -51,10 +51,6 @@ nodes['htz-cloud.wireguard'] = {
}, },
'wireguard': { 'wireguard': {
'snat_ip': '172.19.137.2', 'snat_ip': '172.19.137.2',
'peers': {
'ovh.wireguard': {},
'icinga2': {},
},
}, },
}, },
} }

View file

@ -59,9 +59,6 @@ version = 15
[metadata.wireguard] [metadata.wireguard]
snat_ip = "172.19.136.4" snat_ip = "172.19.136.4"
[metadata.wireguard.peers.'home.router']
[metadata.wireguard.peers.'htz-cloud.wireguard']
[metadata.vm] [metadata.vm]
cpu = 2 cpu = 2
ram = 2 ram = 2