From 25952b49a71ad389dc99006a34712b4f13426d78 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 23 Jan 2017 12:23:46 +0100 Subject: [PATCH 1/3] Add support for multiple backends --- templates/etc/haproxy/frontend.cfg.j2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index fd31102d..d7397a58 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -65,7 +65,13 @@ frontend {{ frontend.name }} {% endfor %} {% if frontend.use_backend is defined %} +{% if frontend.use_backend is iterable %} +{% for use_backend in frontend.use_backend | default([]) %} + use_backend {{ use_backend }} +{% endfor %} +{% else %} use_backend {{ frontend.use_backend }} +{% endif %} {% endif %} default_backend {{ frontend.default_backend }} From b78f0a0b7beb3ad01b19634183c6c1e073177f0b Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 23 Jan 2017 12:55:48 +0100 Subject: [PATCH 2/3] Fix for iterable check --- templates/etc/haproxy/frontend.cfg.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/etc/haproxy/frontend.cfg.j2 b/templates/etc/haproxy/frontend.cfg.j2 index d7397a58..72de8df0 100644 --- a/templates/etc/haproxy/frontend.cfg.j2 +++ b/templates/etc/haproxy/frontend.cfg.j2 @@ -65,7 +65,7 @@ frontend {{ frontend.name }} {% endfor %} {% if frontend.use_backend is defined %} -{% if frontend.use_backend is iterable %} +{% if frontend.use_backend is iterable and frontend.use_backend is not string %} {% for use_backend in frontend.use_backend | default([]) %} use_backend {{ use_backend }} {% endfor %} From dfc785aab017935a80c218ff97e1f9b01a8f2e22 Mon Sep 17 00:00:00 2001 From: Mischa ter Smitten Date: Mon, 23 Jan 2017 12:58:28 +0100 Subject: [PATCH 3/3] Improved documentation [ci skip] --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 205370b7..40445617 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_frontend.{n}.http_response.{n}.action`: [required]: The rules action (e.g. `del-header`) * `haproxy_frontend.{n}.http_response.{n}.param`: [optional]: The complete line to be added (e.g. `X-Varnish`) * `haproxy_frontend.{n}.http_response.{n}.cond`: [optional]: A matching condition built from ACLs -* `haproxy_frontend.{n}.use_backend`: [optional]: Switch to a specific backend if/unless a Layer 7 condition is matched. (e.g. '%[req.hdr(host),lower,map_dom(/etc/haproxy/haproxy_backend.map,bk_default)]') +* `haproxy_frontend.{n}.use_backend`: [optional]: Switch to a specific backend if/unless a Layer 7 condition is matched. (e.g. '%[req.hdr(host),lower,map_dom(/etc/haproxy/haproxy_backend.map,bk_default)]' or `['foo-backend if is_foo', 'bar-backend if is_bar']`) * `haproxy_frontend.{n}.default_backend`: [required]: The backend to use when no `"use_backend"` rule has been matched (e.g. `webservers`) * `haproxy_frontend.{n}.rspadd`: [optional]: Adds headers at the end of the HTTP response * `haproxy_frontend.{n}.rspadd.{n}.string`: [required]: The complete line to be added. Any space or known delimiter must be escaped using a backslash (`'\'`) (in version < 1.6)