ansible-role-wireguard_server/templates/wireguard_server.conf.j2
2024-03-23 00:57:09 +02:00

16 lines
794 B
Django/Jinja

[Interface]
Address = {{ wg_server_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
{% for item in wireguard_peers %}{% if item['name'] != inventory_hostname and 'PublicKey' in item and 'AllowedIPs' in item %}
# Peer name: {{ item.name }}
[Peer]
PublicKey = {{ item.PublicKey }}
AllowedIPs = {{ item.AllowedIPs }}
{% if item.EndPointIP is defined and item.EndPointIP != '' %}
EndPoint = {{ item.EndPointIP }}:{{ listenport }}
{% endif %}
{% endif %}{% endfor %}