From a41231675faa5c7a3ce7c9d817bc7139440c8aad Mon Sep 17 00:00:00 2001 From: Jamison Lofthouse Date: Thu, 8 Apr 2021 15:18:05 -0600 Subject: [PATCH] Check if wireguard_endpoint exists before checking if it is empty (#92) --- templates/etc/wireguard/wg.conf.j2 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 %}