ansible-role-wireguard_server/templates/wireguard_server.conf.j2

17 lines
784 B
Text
Raw Normal View History

2022-10-11 09:19:17 +02:00
[Interface]
Address = {{ address }}
PrivateKey = {{ privatekey }}
ListenPort = {{ listenport }}
PostUp = iptables -t nat -A POSTROUTING -o {{ public_interface }} -j MASQUERADE; ip6tables -t nat -A POSTROUTING -o {{ public_interface }} -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o {{ public_interface }} -j MASQUERADE; ip6tables -t nat -D POSTROUTING -o {{ public_interface }} -j MASQUERADE
2023-04-09 09:17:46 +02:00
{% for item in wireguard_peers %}{% if item['name'] != inventory_hostname and 'PublicKey' in item and 'AllowedIPs' in item %}
2022-10-11 09:19:17 +02:00
2022-11-04 17:00:54 +01:00
# Peer name: {{ item.name }}
2022-10-11 09:19:17 +02:00
[Peer]
PublicKey = {{ item.PublicKey }}
AllowedIPs = {{ item.AllowedIPs }}
2022-11-04 17:00:54 +01:00
{% if item.EndPointIP is defined and item.EndPointIP != '' %}
EndPoint = {{ item.EndPointIP }}:{{ listenport }}
2023-04-06 20:14:52 +02:00
{% endif %}
2023-04-09 09:17:46 +02:00
{% endif %}{% endfor %}