From 35ce36a93a4f1e60129e4775a0a39f05eead02f1 Mon Sep 17 00:00:00 2001 From: Timur Date: Fri, 20 Oct 2017 22:09:07 +0300 Subject: [PATCH 1/2] - added no option to backend and default templates --- README.md | 2 ++ templates/etc/haproxy/backend.cfg.j2 | 4 ++++ templates/etc/haproxy/defaults.cfg.j2 | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 16a2fafd..2a71138e 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_defaults_mode`: [default: `http`]: Set the running mode or protocol of the instance * `haproxy_defaults_source`: [optional]: Set the source address or interface for connections from the proxy * `haproxy_defaults_option`: [default: `[httplog, dontlognull]`]: Options (default) +* `haproxy_defaults_no_option`: [optional]: Options to unset (e.g. `[redispatch]`) * `haproxy_defaults_timeout`: [default: See `defaults/main.yml`]: Timeout declarations * `haproxy_defaults_timeout.type`: [required]: The type (e.g. `connect`, `client`, `server`) * `haproxy_defaults_timeout.timeout`: [required]: The timeout (in in milliseconds by default, but can be in any other unit if the number is suffixed by the unit) (e.g. `5000`, `50000`) @@ -186,6 +187,7 @@ Set up (the latest version of) [HAProxy](http://www.haproxy.org/) in Ubuntu syst * `haproxy_backend.{n}.balance`: [required]: The load balancing algorithm to be used (e.g. `roundrobin`) * `haproxy_backend.{n}.source`: [optional]: Set the source address or interface for connections from the proxy * `haproxy_backend.{n}.option`: [optional]: Options to set (e.g. `[forwardfor]`) +* `haproxy_backend.{n}.no_option`: [optional]: Options to unset (e.g. `[redispatch]`) * `haproxy_backend.{n}.http_check`: [optional]: Make HTTP health checks consider response contents or specific status codes (e.g. `expect status 403`) * `haproxy_backend.{n}.stick`: [optional]: Stick declarations * `haproxy_backend.{n}.stick.{n}.table`: [required]: Configure the stickiness table for the current section (e.g. `type ip size 500k`) diff --git a/templates/etc/haproxy/backend.cfg.j2 b/templates/etc/haproxy/backend.cfg.j2 index fa7ddb34..1ecd1876 100644 --- a/templates/etc/haproxy/backend.cfg.j2 +++ b/templates/etc/haproxy/backend.cfg.j2 @@ -20,6 +20,10 @@ backend {{ backend.name }} option {{ option }} {% endfor %} +{% for option in backend.no_option | default([])%} + no option {{ option }} +{% endfor %} + {% if backend.http_check is defined %} http-check {{ backend.http_check }} {% endif %} diff --git a/templates/etc/haproxy/defaults.cfg.j2 b/templates/etc/haproxy/defaults.cfg.j2 index 4f52e3d4..4a27d9f2 100644 --- a/templates/etc/haproxy/defaults.cfg.j2 +++ b/templates/etc/haproxy/defaults.cfg.j2 @@ -20,6 +20,12 @@ {% endfor %} {% endif %} +{% if haproxy_defaults_no_option != false %} +{% for option in haproxy_defaults_no_option %} + no option {{ option }} +{% endfor %} +{% endif %} + {% if haproxy_defaults_timeout != false %} {% for timeout in haproxy_defaults_timeout %} timeout {{ timeout.type }} {{ timeout.timeout }} From fe28338e48d6f06b23fe4f1376089a20761d0664 Mon Sep 17 00:00:00 2001 From: Timur Date: Fri, 20 Oct 2017 22:26:35 +0300 Subject: [PATCH 2/2] - typo fix; --- templates/etc/haproxy/defaults.cfg.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/etc/haproxy/defaults.cfg.j2 b/templates/etc/haproxy/defaults.cfg.j2 index 4a27d9f2..cf556c4e 100644 --- a/templates/etc/haproxy/defaults.cfg.j2 +++ b/templates/etc/haproxy/defaults.cfg.j2 @@ -20,7 +20,7 @@ {% endfor %} {% endif %} -{% if haproxy_defaults_no_option != false %} +{% if haproxy_defaults_no_option is defined %} {% for option in haproxy_defaults_no_option %} no option {{ option }} {% endfor %}