diff --git a/templates/etc/wireguard/wg.conf.j2 b/templates/etc/wireguard/wg.conf.j2 index 4cb62f7..1427b0c 100644 --- a/templates/etc/wireguard/wg.conf.j2 +++ b/templates/etc/wireguard/wg.conf.j2 @@ -71,10 +71,12 @@ Endpoint = {{hostvars[host].wireguard_endpoint}}:{{hostvars[host].wireguard_port {% else %} Endpoint = {{host}}:{{hostvars[host].wireguard_port}} {% endif %} -{% elif hostvars[host].wireguard_endpoint is defined and hostvars[host].wireguard_endpoint != "" %} +{% elif hostvars[host].wireguard_endpoint is defined %} +{% if hostvars[host].wireguard_endpoint != "" %} Endpoint = {{hostvars[host].wireguard_endpoint}}:{{wireguard_port}} -{% elif hostvars[host].wireguard_endpoint == "" %} +{% else %} # No endpoint defined for this peer +{% endif %} {% else %} Endpoint = {{host}}:{{wireguard_port}} {% endif %}