From f7c87fd118fe9ba7a302df0bc3647255b4b9435f Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Tue, 14 Feb 2023 18:40:55 +0000 Subject: [PATCH] Add a variable to allow extra raw config to be applied to all frontends Currently this must be configured on a per-frontend basis through service.haproxy_frontend_raw. This patch adds a new role default variable haproxy_frontend_extra_raw which will be combined with all per service raw config lines. Change-Id: I506d46d64df93bbb9e6d1ebfa3d3caa44c80fdd5 --- defaults/main.yml | 4 ++++ templates/service.j2 | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/defaults/main.yml b/defaults/main.yml index 652a941..e299672 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -45,6 +45,10 @@ haproxy_stats_prometheus_enabled: False # defined for each service. haproxy_backup_nodes: [] +# Configuration lines to write directly into all frontends +haproxy_frontend_extra_raw: [] +haproxy_frontend_redirect_extra_raw: "{{ haproxy_frontend_extra_raw }}" + haproxy_service_configs: [] # Example: # haproxy_service_configs: diff --git a/templates/service.j2 b/templates/service.j2 index 7fc837c..2e33f16 100644 --- a/templates/service.j2 +++ b/templates/service.j2 @@ -39,6 +39,9 @@ bind {{ vip_address }}:{{ item.service.haproxy_redirect_http_port }}{{ (vip_inte acl {{ key }} {{ value.rule }} use_backend {{ value.backend_name | default(item.service.haproxy_service_name) }}-back if {{ key }} {% endfor %} +{% for entry in haproxy_frontend_redirect_extra_raw %} + {{ entry }} +{% endfor %} {% endif %} {% endif %} {% endif %} @@ -83,7 +86,7 @@ frontend {{ item.service.haproxy_service_name }}-front-{{ loop.index }} {% if not item.service.haproxy_frontend_only | default(false) %} default_backend {{ item.service.haproxy_service_name }}-back {% endif %} -{% for entry in item.service.haproxy_frontend_raw|default([]) %} +{% for entry in (item.service.haproxy_frontend_raw|default([])) + haproxy_frontend_extra_raw %} {{ entry }} {% endfor %} {% endif %}