ansible-haproxy icon indicating copy to clipboard operation
ansible-haproxy copied to clipboard

http-check parameters

Open asosso opened this issue 3 years ago • 3 comments

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...

asosso avatar Jun 13 '21 17:06 asosso

The approach you're suggesting is fine. I think we already have something similar in the templates, but not for http_check.

tersmitten avatar Jul 14 '21 08:07 tersmitten

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.

michalsarna avatar Aug 24 '21 19:08 michalsarna

Same modifications here ( suggested by @asosso ), working as expected now.

x-drum avatar Oct 06 '21 07:10 x-drum

Any progress here? Such functionality would also be necessary for me.

tbauriedel avatar Jun 06 '23 12:06 tbauriedel

Is there already a PR I missed?

tersmitten avatar Jun 09 '23 09:06 tersmitten

@tersmitten, I took the liberty of putting @asosso suggested solution into a PR. #144

tbauriedel avatar Jun 12 '23 06:06 tbauriedel