[Interface] Address = {% for item in wireguard_peers %}{% if item['name'] == inventory_hostname %}{{ item['AllowedIPs'] }} {% endif %}{% endfor %} PrivateKey = {{ private_key }} ListenPort = {{ listenport }} DNS = {% if vpn_dns is defined %}{{ vpn_dns }}{% else %}{{ server_address }}{% endif %} {% 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 }}:{{ item.listenport | default(listenport) }} {% endif %}{% endif %}{% endfor %}