From 2583dd4264cf0eec4f342076d5b19799bdcd3d3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Bourqui?= Date: Fri, 18 Oct 2019 19:30:23 +0200 Subject: [PATCH] use ansible_play_hosts instead of hardcoded vpn grp should use the group in the play calling the role. works fine when hosts bellong to several groups --- templates/wg.conf.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/wg.conf.j2 b/templates/wg.conf.j2 index 81e0d48..3d381bb 100644 --- a/templates/wg.conf.j2 +++ b/templates/wg.conf.j2 @@ -16,7 +16,7 @@ PostDown = {{hostvars[inventory_hostname].wireguard_postdown}} SaveConfig = true {% endif %} -{% for host in groups["vpn"] %} +{% for host in ansible_play_hosts %} {% if host != inventory_hostname %} [Peer] PublicKey = {{hostvars[host].public_key}}