From 81d13cddc5de612ebc4e56ec9f171c95dfb4938b Mon Sep 17 00:00:00 2001 From: Alfvar Date: Sun, 18 May 2025 17:28:50 +0200 Subject: [PATCH] Added `wireguard_always_listen` to force ListenPort without setting an endpoint --- templates/etc/wireguard/wg.conf.j2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templates/etc/wireguard/wg.conf.j2 b/templates/etc/wireguard/wg.conf.j2 index ea1f8eb..0ab7293 100644 --- a/templates/etc/wireguard/wg.conf.j2 +++ b/templates/etc/wireguard/wg.conf.j2 @@ -15,7 +15,8 @@ Address = {{ wg_addr }} {% endfor %} {% endif %} PrivateKey = {{ wireguard_private_key }} -{% if wireguard_endpoint is defined and wireguard_endpoint != "" %} +{% set always = wireguard_always_listen|default(false) %} +{% if always or (wireguard_endpoint is defined and wireguard_endpoint != "") or (ansible_play_hosts|length <= 1) %} ListenPort = {{ wireguard_port }} {% endif %} {% if wireguard_dns is defined %}