Merge "Allow default_backend to be specified"

This commit is contained in:
Zuul 2023-03-15 18:07:58 +00:00 committed by Gerrit Code Review
commit 56fef3de83
3 changed files with 13 additions and 2 deletions

View File

@ -88,6 +88,7 @@ haproxy_service_configs: []
# haproxy_frontend_raw:
# - 'http-request use-service prometheus-exporter if { path /metrics }'
# haproxy_service_enabled: True
# haproxy_default_backend: other_backend
galera_monitoring_user: monitoring
haproxy_bind_on_non_local: False

View File

@ -0,0 +1,10 @@
---
features:
- |
A new key ``haproxy_default_backend`` can be defined for each service
configured in the haproxy loadbalancer. Configuring this variable writes
a value for the ``default_backend`` directive into the config for the
service frontend. It can be useful to provide a specific default backend
as a fall-through option when other backends are selected using ACLs,
and to also allow the name of the default backend to be different from
``haproxy_service_name``.

View File

@ -83,8 +83,8 @@ frontend {{ item.service.haproxy_service_name }}-front-{{ loop.index }}
http-request add-header X-Forwarded-Proto https
{% endif %}
mode {{ item.service.haproxy_balance_type }}
{% if not item.service.haproxy_frontend_only | default(false) %}
default_backend {{ item.service.haproxy_service_name }}-back
{% if (not item.service.haproxy_frontend_only | default(false)) or ((item.service.haproxy_default_backend is defined) and (item.service.haproxy_default_backend | length > 0)) %}
default_backend {{ item.service.haproxy_default_backend | default(item.service.haproxy_service_name) }}-back
{% endif %}
{% for entry in (item.service.haproxy_frontend_raw|default([])) + haproxy_frontend_extra_raw %}
{{ entry }}