ansible-role-wireguard_client/templates/wireguard_client.conf

27 lines
1.1 KiB
Text
Raw Normal View History

2022-10-11 09:19:16 +02:00
[Interface]
2023-10-05 09:42:02 +02:00
Address = {{ wg_address | default(AllowedIPs) }}
2022-11-04 16:55:00 +01:00
PrivateKey = {{ private_key }}
2022-10-11 09:19:16 +02:00
ListenPort = {{ listenport }}
2023-10-05 09:41:23 +02:00
{% if vpn_dns is defined %}DNS = {{ vpn_dns }}{% endif %}
2022-10-11 09:19:16 +02:00
2023-10-05 10:11:59 +02:00
# From inventory
2024-05-19 12:53:47 +02:00
{% for item in groups['wireguard_clients'] %}{% if hostvars[item]['inventory_hostname'] != inventory_hostname and 'PublicKey' in hostvars[item] and 'AllowedIPs' in hostvars[item] and hostvars[item]['PublicKey'] != ""%}
2023-10-05 09:59:33 +02:00
# Peer name: {{ item }}
2022-10-11 09:19:16 +02:00
[Peer]
2023-10-05 09:59:33 +02:00
PublicKey = {{ hostvars[item]['PublicKey'] }}
AllowedIPs = {{ hostvars[item]['AllowedIPs'] }}
{% if hostvars[item]['EndPointIP'] is defined and hostvars[item]['EndPointIP'] != '' %}EndPoint = {{ hostvars[item]['EndPointIP'] }}:{{ hostvars[item]['listenport'] | default(listenport) }}
2023-08-09 13:57:22 +02:00
{% endif %}{% endif %}{% endfor %}
2023-10-05 10:11:59 +02:00
# From peers configuration
{% 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 %}