[Interface] PrivateKey = {{ lookup('ansible.builtin.ini', 'private_key section=wireguard file=secrets/' + inventory_hostname + '.ini') }} ListenPort = 51822 Address = {{ wireguard_ip }} {% for host in hostvars %} {% if host != inventory_hostname %} # {{ host }} [Peer] Endpoint = {{ hostvars[host].wireguard_endpoint|default(host) }}:51822 PublicKey = {{ hostvars[host].wireguard_pubkey }} AllowedIPs = {{ hostvars[host].wireguard_ip }} {% endif %}{% endfor %}