From b6c4c33fa0aaea47cc90e3b8e5e67ce2ab12d36b Mon Sep 17 00:00:00 2001 From: "Antonio J. Delgado" Date: Thu, 5 Oct 2023 10:59:33 +0300 Subject: [PATCH] fix template for hostvars --- templates/wireguard_client.conf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/wireguard_client.conf b/templates/wireguard_client.conf index a848b79..1ceb35e 100644 --- a/templates/wireguard_client.conf +++ b/templates/wireguard_client.conf @@ -4,11 +4,11 @@ PrivateKey = {{ private_key }} ListenPort = {{ listenport }} {% if vpn_dns is defined %}DNS = {{ vpn_dns }}{% endif %} -{% for item in groups['wireguard_clients'] %}{% if item['inventory_hostname'] != inventory_hostname and 'PublicKey' in item and 'AllowedIPs' in item %} +{% for item in groups['wireguard_clients'] %}{% if hostvars[item]['inventory_hostname'] != inventory_hostname and 'PublicKey' in hostvars[item] and 'AllowedIPs' in hostvars[item] %} -# Peer name: {{ item.inventory_hostname }} +# Peer name: {{ item }} [Peer] -PublicKey = {{ item.PublicKey }} -AllowedIPs = {{ item.AllowedIPs }} -{% if item.EndPointIP is defined and item.EndPointIP != '' %}EndPoint = {{ item.EndPointIP }}:{{ item.listenport | default(listenport) }} +PublicKey = {{ hostvars[item]['PublicKey'] }} +AllowedIPs = {{ hostvars[item]['AllowedIPs'] }} +{% if hostvars[item]['EndPointIP'] is defined and hostvars[item]['EndPointIP'] != '' %}EndPoint = {{ hostvars[item]['EndPointIP'] }}:{{ hostvars[item]['listenport'] | default(listenport) }} {% endif %}{% endif %}{% endfor %}