bundlewrap/bundles/wireguard/items.py

32 lines
827 B
Python
Raw Normal View History

2021-04-01 14:27:31 +00:00
from ipaddress import ip_network
repo.libs.tools.require_bundle(node, 'systemd-networkd')
2021-04-01 14:27:31 +00:00
network = ip_network(node.metadata['wireguard']['my_ip'], strict=False)
files = {
2021-04-01 14:27:31 +00:00
'/etc/systemd/network/wg0.netdev': {
'content_type': 'mako',
2021-04-01 14:27:31 +00:00
'context': {
'network': f'{network.network_address}/{network.prefixlen}',
**node.metadata['wireguard'],
},
'needs': {
'pkg_apt:wireguard',
},
'triggers': {
'svc_systemd:systemd-networkd:restart',
},
},
2020-11-21 15:15:34 +00:00
'/usr/local/share/icinga/plugins/check_wireguard_connected': {
'mode': '0755',
},
}
if node.has_bundle('pppd'):
files['/etc/ppp/ip-up.d/reconnect-wireguard'] = {
'source': 'pppd-ip-up',
'content_type': 'mako',
'mode': '0755',
}