diff --git a/templates/etc/wireguard/wg.conf.j2 b/templates/etc/wireguard/wg.conf.j2 index ea1f8eb..7eecfbc 100644 --- a/templates/etc/wireguard/wg.conf.j2 +++ b/templates/etc/wireguard/wg.conf.j2 @@ -54,7 +54,7 @@ PostDown = {{ wg_postdown }} SaveConfig = {{ wireguard_save_config }} {% endif %} {% for host in ansible_play_hosts %} -{% if host != inventory_hostname and ((hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "") or (wireguard_endpoint is defined and wireguard_endpoint != "")) %} +{% if host != inventory_hostname and hostvars[host].wireguard__fact_public_key is defined and ((hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "") or (wireguard_endpoint is defined and wireguard_endpoint != "")) %} [Peer] # Name = {{ host }}