{{ ansible_managed | comment }}

[Interface]
PrivateKey = {{ item.value.private_key }}
{% if "listen_port" in item.value %}
ListenPort = {{ item.value.listen_port }}
{% endif %}

[Peer]
PublicKey = {{ item.value.peer_public_key }}
AllowedIPs = {{ item.value.peer_allowed_addresses | join(", ") }}
PersistentKeepalive = {{ item.value.peer_keepalive
                         | default(ifupdown2__wireguard_keepalive) }}
{% if "peer_endpoint" in item.value %}
Endpoint = {{ item.value.peer_endpoint }}
{% endif %}