From 4513bc84ae351f0bb51b8b0106bbf2e5269f8649 Mon Sep 17 00:00:00 2001 From: Marc Gariepy Date: Wed, 12 Jul 2023 13:46:43 -0400 Subject: [PATCH] Add ability to have different backend port. Add the possibility to have multiple backend services running on differents ports. Change-Id: I1748bfc15bdf879f78aa06c385af7b6c45bde7ff --- .../notes/backend_config_per_host-14cec3ec5f708934.yaml | 7 +++++++ templates/service.j2 | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/backend_config_per_host-14cec3ec5f708934.yaml diff --git a/releasenotes/notes/backend_config_per_host-14cec3ec5f708934.yaml b/releasenotes/notes/backend_config_per_host-14cec3ec5f708934.yaml new file mode 100644 index 0000000..af4ca56 --- /dev/null +++ b/releasenotes/notes/backend_config_per_host-14cec3ec5f708934.yaml @@ -0,0 +1,7 @@ +--- +features: + - HAProxy services that use backend nodes that are not + in the Ansible inventory can now have the ``backend_port`` + specified in the list, along with ``name`` or ``ip_addr`` settings. + This allow to have the service bound to different port on different + backend servers. diff --git a/templates/service.j2 b/templates/service.j2 index aa43f00..b67f908 100644 --- a/templates/service.j2 +++ b/templates/service.j2 @@ -134,10 +134,10 @@ backend {{ service.haproxy_service_name }}-back {% set entry = [] %} {% set _ = entry.append("server") %} {% set _ = entry.append((host_name.name | default(host_name)) | string) %} -{% set _ = entry.append((host_name.ip_addr | default(ip_addr)) + ":" + haproxy_backend_port | string) %} +{% set _ = entry.append((host_name.ip_addr | default(ip_addr)) + ":" + (host_name.backend_port | default(haproxy_backend_port)) | string) %} {% set _ = entry.append("check") %} {% set _ = entry.append("port") %} -{% set _ = entry.append(haproxy_check_port | string) %} +{% set _ = entry.append(host_name.backend_port | default(haproxy_check_port) | string) %} {% set _ = entry.append("inter") %} {% set _ = entry.append(service.interval|default(haproxy_interval) | string) %} {% set _ = entry.append("rise") %}