[NetDev] Name=wg0 Kind=wireguard Description=WireGuard tunnel wg0 [WireGuard] ListenPort=51871 PrivateKey={{ wg0_private_key }} {% for item in hosts_wg0 %} {% if item != inventory_hostname %} [WireGuardPeer] PublicKey={{ hostvars[item].wg0_public_key }} PresharedKey={{ hostvars[item]['wg0_psk_' ~ inventory_hostname] }} AllowedIPs={{ hostvars[item].wg0_ip }}/32 Endpoint={{ hostvars['localhost'].nodes_to_ipv4s_private[item] }}:51871 {% endif %} {% endfor %}