summaryrefslogtreecommitdiff
path: root/roles/network/wireguard/p2p/templates/systemd.netdev.j2
blob: 3e73f474e2946ec06c0f1f3108af07def1100edf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
[NetDev]
Name={{ wireguard_p2p_interface.name }}
Kind=wireguard
{% if 'description' in wireguard_p2p_interface %}
Description={{ wireguard_p2p_interface.description }}
{% endif %}


[WireGuard]
{% if 'priv_key' in wireguard_p2p_interface %}
PrivateKey={{ wireguard_p2p_interface.priv_key }}
{% else %}
PrivateKeyFile=/etc/systemd/network/{{ wireguard_p2p_interface.name }}.privkey
{% endif %}
{% if 'listen_port' in wireguard_p2p_interface %}
ListenPort={{ wireguard_p2p_interface.listen_port }}
{% endif %}

{% for peer in wireguard_p2p_peers %}

[WireGuardPeer]
PublicKey={{ peer.pub_key }}
{%   for ip in peer.allowed_ips %}
AllowedIPs={{ ip }}
{%   endfor %}
{%   if 'endpoint' in peer %}
Endpoint={{ peer.endpoint.host }}:{{ peer.endpoint.port | default(51820) }}
{%   endif %}
{%   if 'keepalive_interval' in peer %}
PersistentKeepalive={{ peer.keepalive_interval }}
{%   endif %}
{% endfor %}