From 4a503a05fad1fb6c3a432cca921d61f3cd334971 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franti=C5=A1ek=20Dvo=C5=99=C3=A1k?= <valtri@civ.zcu.cz>
Date: Thu, 13 Jun 2024 20:04:22 +0000
Subject: [PATCH] Support both IPv4/IPv6 universally in squid configuration

---
 .../playbooks/templates/etc/squid/conf.d/allcluster.conf     | 4 ++++
 staging/playbooks/templates/etc/squid/conf.d/allcluster.conf | 5 +----
 2 files changed, 5 insertions(+), 4 deletions(-)
 mode change 100644 => 120000 staging/playbooks/templates/etc/squid/conf.d/allcluster.conf

diff --git a/cesnet-central/playbooks/templates/etc/squid/conf.d/allcluster.conf b/cesnet-central/playbooks/templates/etc/squid/conf.d/allcluster.conf
index 1449303..56885f9 100644
--- a/cesnet-central/playbooks/templates/etc/squid/conf.d/allcluster.conf
+++ b/cesnet-central/playbooks/templates/etc/squid/conf.d/allcluster.conf
@@ -1,7 +1,11 @@
 {% for host in groups['ingress'] + groups['nfs'] + groups['worker'] + groups['gpu'] -%}
+{% if hostvars[host].ansible_default_ipv6.address is defined %}
 acl allcluster src {{ hostvars[host].ansible_default_ipv6.address }}
+{% endif %}
 {% endfor -%}
 {% for host in groups['ingress'] + groups['nfs'] + groups['worker'] + groups['gpu'] -%}
+{% if hostvars[host].ansible_default_ipv4.address is defined %}
 acl allcluster src {{ hostvars[host].ansible_default_ipv4.address }}
+{% endif %}
 {% endfor -%}
 http_access allow allcluster
diff --git a/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf b/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf
deleted file mode 100644
index 2bd0926..0000000
--- a/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-{% for host in groups['ingress'] + groups['nfs'] + groups['worker'] + groups['gpu'] -%}
-acl allcluster src {{ hostvars[host].ansible_default_ipv4.address }}
-{% endfor -%}
-http_access allow allcluster
diff --git a/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf b/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf
new file mode 120000
index 0000000..3ac6e9a
--- /dev/null
+++ b/staging/playbooks/templates/etc/squid/conf.d/allcluster.conf
@@ -0,0 +1 @@
+../../../../../../cesnet-central/playbooks/templates/etc/squid/conf.d/allcluster.conf
\ No newline at end of file
-- 
GitLab