ansible/roles/wireguard/templates/wg0.conf.j2

23 lines
697 B
Plaintext
Raw Normal View History

2022-09-06 16:11:48 +02:00
[Interface]
2022-09-06 17:40:19 +02:00
PrivateKey = {{ wg_peers.get(inventory_hostname).private_key }}
ListenPort = {{ wg_listen_port }}
Address = {{ wg_peers.get(inventory_hostname).address }}
DNS = {{ wg_dns }}
2022-09-06 16:11:48 +02:00
2022-09-06 17:40:19 +02:00
{% for peer_hostname, peer_data in wg_peers.items() %}
2022-09-06 16:11:48 +02:00
{% if peer_hostname != inventory_hostname %}
[Peer] # {{ peer_hostname }}
PublicKey = {{ peer_data.public_key }}
2022-09-06 17:40:19 +02:00
Endpoint = {{ peer_data.endpoint }}:{{ wg_listen_port }}
2022-09-06 16:11:48 +02:00
AllowedIPs = {{ peer_data.allowed_ips }}
2022-09-06 17:40:19 +02:00
PersistentKeepalive = {{ wg_persistent_keepalive }}
2022-09-06 16:11:48 +02:00
PresharedKey = {{
2022-09-06 17:40:19 +02:00
wg_preshared_keys.get(
2022-09-06 18:10:43 +02:00
inventory_hostname + "_" + peer_hostname,
wg_preshared_keys.get(peer_hostname + "_" + inventory_hostname)
2022-09-06 16:11:48 +02:00
)
}}
{% endif %}
{% endfor %}