Add custom errorfiles

Change-Id: Ifc4feeffc951ec03745bf65d51db5e4917f1be29
This commit is contained in:
Daniel 'f0o' Preussker 2025-04-08 11:17:51 +00:00 committed by Daniel Preussker
parent 240d109cc8
commit 5da10f8559
3 changed files with 37 additions and 0 deletions

View File

@ -330,3 +330,32 @@ haproxy_static_files_extra: []
haproxy_static_files: "{{ haproxy_static_files_default + haproxy_static_files_extra }}"
haproxy_sysctl_file: "{{ openstack_sysctl_file | default('/etc/sysctl.conf') }}"
# Allows to define custom errorfiles in the format:
# - code: 504
# path: /path/to/504.http
# You can use haproxy_static_files_extra to add those files.
# See https://github.com/haproxy/haproxy/tree/master/examples/errorfiles for examples
#
# An example combination of haproxy_static_files_extra and haproxy_errorfiles:
# haproxy_static_files_extra:
# - dest: /etc/haproxy/500.http
# content: |
# HTTP/1.0 500 Internal Server Error
# Cache-Control: no-cache
# Connection: close
# Content-Type: text/html
#
# <html><body><h1>500 Internal Server Error</h1>
# This Server Made a Boo Boo
# </body></html>
# - dest: /etc/haproxy/504.http
# content: "{{ lookup('file', '/etc/openstack_deploy/haproxy/504.http') }}"
#
# haproxy_errorfiles:
# - code: 500
# path: /etc/haproxy/500.http
# - code: 504
# path: /etc/haproxy/504.http
#
haproxy_errorfiles: []

View File

@ -0,0 +1,5 @@
---
features:
- |
Added support for defining custom error files using haproxy_errorfiles.
These files can be distributed alongside haproxy_static_files_extra.

View File

@ -36,6 +36,9 @@ defaults
timeout http-request {{ haproxy_http_request_timeout }}
timeout server {{ haproxy_server_timeout }}
maxconn {{ haproxy_maxconn }}
{% for value in haproxy_errorfiles %}
errorfile {{ value.code }} {{ value.path }}
{% endfor %}
{% if haproxy_stats_enabled | bool %}
{% set haproxy_ssl_path = haproxy_ssl_cert_path + "/haproxy_" + (haproxy_host | default(ansible_facts['hostname'])) + "-" + ((haproxy_bind_internal_lb_vip_interface is truthy) | ternary(haproxy_bind_internal_lb_vip_address ~ '-' ~ haproxy_bind_internal_lb_vip_interface, haproxy_bind_internal_lb_vip_address)) + ".pem" %}
listen stats