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
This commit is contained in:
Jonathan Rosser 2023-02-14 18:40:55 +00:00
parent 445b15f9c3
commit f7c87fd118
2 changed files with 8 additions and 1 deletions

View File

@ -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:

View File

@ -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 %}