From 75edc133072fb9fcd436846423638651eb990d36 Mon Sep 17 00:00:00 2001 From: Jonathan Rosser Date: Wed, 8 Mar 2023 12:01:51 +0000 Subject: [PATCH] Use a map file to select haproxy horizon backend from the base frontend This is the smallest change to demonstrate the use of a map file with haproxy. A 'map_reg' type regular expression map is used to match any traffic arriving at the base frontend and direct it to the horizon backend, which duplicates the current behaviour. The map file contents used behave the same as the 'default_backend' config directive on a frontend. Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-haproxy_server/+/876749 Depends-On: https://review.opendev.org/c/openstack/openstack-ansible-haproxy_server/+/878771 Change-Id: I95d0d2523c8452aeb624923b40a55c09d9341ac3 --- inventory/group_vars/haproxy/haproxy.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/inventory/group_vars/haproxy/haproxy.yml b/inventory/group_vars/haproxy/haproxy.yml index 9780c28bea..f5429203bd 100644 --- a/inventory/group_vars/haproxy/haproxy.yml +++ b/inventory/group_vars/haproxy/haproxy.yml @@ -90,7 +90,12 @@ haproxy_base_service: haproxy_frontend_acls: "{{ (haproxy_ssl_letsencrypt_enable | bool and haproxy_ssl | bool) | ternary(haproxy_ssl_letsencrypt_acl, {}) }}" haproxy_acls: "{{ keystone_security_txt_content is defined | ternary(haproxy_security_txt_acl, {}) }}" haproxy_frontend_raw: "{{ (haproxy_ssl | bool and haproxy_security_headers is defined) | ternary( haproxy_security_headers + [ haproxy_horizon_csp | default(haproxy_security_headers_csp)], []) }}" - haproxy_default_backend: "{{ (groups['horizon_all'] | length > 0) | ternary('horizon', '') }}" + haproxy_maps: + - 'use_backend %[path,map_reg(/etc/haproxy/base_regex.map)]' + haproxy_map_entries: + - name: base_regex + entries: + - "#Regular expression map file - this comment is defined in the base frontend config" haproxy_adjutant_api_service: haproxy_service_name: adjutant_api @@ -250,6 +255,11 @@ haproxy_horizon_service: - "httpchk HEAD /auth/login/ HTTP/1.0\\r\\nUser-agent:\\ osa-haproxy-healthcheck" haproxy_service_enabled: "{{ groups['horizon_all'] is defined and groups['horizon_all'] | length > 0 }}" haproxy_stick_table: "{{ openstack_haproxy_horizon_stick_table }}" + haproxy_map_entries: + - name: base_regex + #match any requests to the horizon backend + entries: + - '.* horizon-back' haproxy_ironic_api_service: haproxy_service_name: ironic_api