2024-10-14 02:27:27 +00:00
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
[Interface] # {{ ansible_hostname }}
|
2021-05-07 04:24:52 +00:00
|
|
|
PrivateKey = {{ wgkey['content'] | b64decode | trim }}
|
|
|
|
Address = {{ wireguard.address }}
|
|
|
|
{% if wireguard.listenport is defined %}
|
|
|
|
ListenPort = {{ wireguard.listenport }}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% for peer in wireguard.peers %}
|
2024-10-14 02:27:27 +00:00
|
|
|
{% if peer.name is defined %}
|
|
|
|
[Peer] # {{ peer.name }}
|
|
|
|
{% else %}
|
2021-05-07 04:24:52 +00:00
|
|
|
[Peer]
|
2024-10-14 02:27:27 +00:00
|
|
|
{% endif %}
|
2021-05-07 04:24:52 +00:00
|
|
|
PublicKey = {{ peer.publickey }}
|
2024-09-11 02:35:20 +00:00
|
|
|
{% if peer.presharedkey is defined %}
|
|
|
|
PresharedKey = {{ peer.presharedkey }}
|
2024-10-14 02:27:27 +00:00
|
|
|
{% else %}
|
|
|
|
{% set preshared_key = (
|
|
|
|
wgshared.results
|
|
|
|
| selectattr('item.item.name', 'equalto', peer.name)
|
|
|
|
| first
|
|
|
|
).content
|
|
|
|
| default(none)
|
|
|
|
%}
|
|
|
|
{% if preshared_key is not none %}
|
|
|
|
PresharedKey = {{ preshared_key | b64decode | trim }}
|
|
|
|
{% endif %}
|
2024-09-11 02:35:20 +00:00
|
|
|
{% endif %}
|
2021-05-07 04:24:52 +00:00
|
|
|
{% if peer.endpoint is defined %}
|
|
|
|
Endpoint = {{ peer.endpoint }}
|
|
|
|
{% endif %}
|
|
|
|
AllowedIPs = {{ peer.allowedips }}
|
|
|
|
{% if peer.keepalive is defined %}
|
|
|
|
PersistentKeepalive = {{ peer.keepalive }}
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% endfor %}
|