[Interface] Address = {{ wg_address | default(AllowedIPs) }} PrivateKey = {{ private_key }} ListenPort = {{ listenport }} {% if vpn_dns is defined %}DNS = {{ vpn_dns }}{% endif %} {% for item in groups['wireguard_clients'] %}{% if hostvars[item]['inventory_hostname'] != inventory_hostname and 'PublicKey' in hostvars[item] and 'AllowedIPs' in hostvars[item] %} # Peer name: {{ item }} [Peer] PublicKey = {{ hostvars[item]['PublicKey'] }} AllowedIPs = {{ hostvars[item]['AllowedIPs'] }} {% if hostvars[item]['EndPointIP'] is defined and hostvars[item]['EndPointIP'] != '' %}EndPoint = {{ hostvars[item]['EndPointIP'] }}:{{ hostvars[item]['listenport'] | default(listenport) }} {% endif %}{% endif %}{% endfor %}