From 8fe780a8b1e67bdb2732ee17ff0fcb746a5ce750 Mon Sep 17 00:00:00 2001
From: Blallo <blallo@autistici.org>
Date: Sat, 11 Dec 2021 00:05:52 +0100
Subject: [PATCH] Support new syntax in haproxy

---
 roles/float-infra-haproxy/templates/haproxy.cfg.j2 | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/roles/float-infra-haproxy/templates/haproxy.cfg.j2 b/roles/float-infra-haproxy/templates/haproxy.cfg.j2
index e8dce8b4..ae75f571 100644
--- a/roles/float-infra-haproxy/templates/haproxy.cfg.j2
+++ b/roles/float-infra-haproxy/templates/haproxy.cfg.j2
@@ -31,16 +31,18 @@ defaults
 {% if ep.get('ports', []) %}
 
 {% for port in ep.ports %}
-frontend fe_{{ service_name }}_{{ ep.name }}_{{ port }}
-        bind :::{{ port }}
-        default_backend be_{{ service_name }}_{{ ep.name }}_{{ port }}
+{% set internal = port.internal | default(port) %}
+{% set public = port.public | default(port) %}
+frontend fe_{{ service_name }}_{{ ep.name }}_{{ public }}
+        bind :::{{ public }}
+        default_backend be_{{ service_name }}_{{ ep.name }}_{{ internal }}
 
-backend be_{{ service_name }}_{{ ep.name }}_{{ port }}
+backend be_{{ service_name }}_{{ ep.name }}_{{ internal }}
         log global
         balance leastconn
         option independent-streams
 {% for s in services[service_name].hosts|sort %}
-        server task{{ loop.index -1 }} {{ s }}.{{ service_name }}.{{ domain }}:{{ port }} check fall 3 id {{ loop.index + 999 }} inter 5000 rise 3 slowstart 60000 weight 50{% if ep.get('use_proxy_protocol') %} send-proxy-v2{% endif %}
+        server task{{ loop.index -1 }} {{ s }}.{{ service_name }}.{{ domain }}:{{ internal }} check fall 3 id {{ loop.index + 999 }} inter 5000 rise 3 slowstart 60000 weight 50{% if ep.get('use_proxy_protocol') %} send-proxy-v2{% endif %}
 
 {% endfor %}
 
-- 
GitLab