From 739c9de73ee584e064b28a7d23acc5d00b80f48d Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Sun, 20 Sep 2020 00:39:14 +0200 Subject: [PATCH] Move wireguard_ip template code to template where it belongs Instead of redundant set_fact task. --- tasks/main.yml | 4 ---- templates/etc/wireguard/wg.conf.j2 | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 23c58fd..cd2072d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -24,10 +24,6 @@ - wg-install when: not ansible_os_family == 'Darwin' -- name: Set WireGuard IP (without mask) - set_fact: - wireguard_ip: "{{ wireguard_address.split('/')[0] }}" - - name: Register if config/private key already exists on target host stat: path: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf" diff --git a/templates/etc/wireguard/wg.conf.j2 b/templates/etc/wireguard/wg.conf.j2 index 9416600..1a8d489 100644 --- a/templates/etc/wireguard/wg.conf.j2 +++ b/templates/etc/wireguard/wg.conf.j2 @@ -50,7 +50,7 @@ PublicKey = {{hostvars[host].wireguard__fact_public_key}} {% if hostvars[host].wireguard_allowed_ips is defined %} AllowedIPs = {{hostvars[host].wireguard_allowed_ips}} {% else %} -AllowedIPs = {{hostvars[host].wireguard_ip}}/32 +AllowedIPs = {{ hostvars[host].wireguard_address.split('/')[0] }}/32 {% endif %} {% if hostvars[host].wireguard_persistent_keepalive is defined %} PersistentKeepalive = {{hostvars[host].wireguard_persistent_keepalive}}