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

23 lines
697 B
Django/Jinja

[Interface]
PrivateKey = {{ wg_peers.get(inventory_hostname).private_key }}
ListenPort = {{ wg_listen_port }}
Address = {{ wg_peers.get(inventory_hostname).address }}
DNS = {{ wg_dns }}
{% for peer_hostname, peer_data in wg_peers.items() %}
{% if peer_hostname != inventory_hostname %}
[Peer] # {{ peer_hostname }}
PublicKey = {{ peer_data.public_key }}
Endpoint = {{ peer_data.endpoint }}:{{ wg_listen_port }}
AllowedIPs = {{ peer_data.allowed_ips }}
PersistentKeepalive = {{ wg_persistent_keepalive }}
PresharedKey = {{
wg_preshared_keys.get(
inventory_hostname + "_" + peer_hostname,
wg_preshared_keys.get(peer_hostname + "_" + inventory_hostname)
)
}}
{% endif %}
{% endfor %}