ansible-haproxy
ansible-haproxy copied to clipboard
http-check parameters
Hi,
http-check
directive could be used multiple times in backend/listen
- http-check comment
- http-check connect
- http-check disable-on-404
- http-check expect
- http-check send
- http-check send-state
- http-check set-var
- http-check unset-var
Docs here: https://cbonte.github.io/haproxy-dconv/2.4/configuration.html#4-http-check%20comment Some examples here: https://www.haproxy.com/blog/announcing-haproxy-2-2/
Changing the template as follow could be backward compatibile
From:
{% if backend.http_check is defined %}
http-check {{ backend.http_check }}
{% endif %}
To:
{% if backend.http_check is defined %}
{% if backend.http_check is string %}
http-check {{ backend.http_check }}
{% else %}
{% for http_check in backend.http_check %}
http-check {{ http_check }}
{% endfor %}
{% endif %}
{% endif %}
Working examples:
http_check: expect status 200
http_check:
- send meth GET uri /healthz
- expect status 200
Proposal for the README.md:
-
haproxy_listen.{n}.http_check.{n}
: [optional]: Configure HTTP health checks (e.g.expect status 403
,send meth GET uri /healthz
)
Do you prefer this approach or should we define an if condition for each http-check parameters?
I.e.
-
haproxy_listen.{n}.http_check_send
-
haproxy_listen.{n}.http_check_comment
-
haproxy_listen.{n}.http_check_connect
- etc...
The approach you're suggesting is fine. I think we already have something similar in the templates, but not for http_check
.
I've did almost the same modifications. This is important to be able to add multiple options since HAproxy 2.4 requires multiple https-check fields to be able to work properly.
Same modifications here ( suggested by @asosso ), working as expected now.
Any progress here? Such functionality would also be necessary for me.
Is there already a PR I missed?
@tersmitten, I took the liberty of putting @asosso suggested solution into a PR. #144