0

I have a lot of sites and I want to do a http healthcheck for each one. Does it mean that I need to make a backend section for each site? If so, I need to generate it somehow. Can I achieve it with templates or may be with something like ansible?

Example of one of backend sections:

backend domain1.com
  redirect scheme https if !{ ssl_fc }
  option httpchk GET /healthcheck HTTP/1.1\r\nHost:\ domain1.com
  default-server inter 1s fall 3 rise 2
  http-check expect ! rstatus ^5
    server server01 server01:443 check ssl verify none
    server server02 server02:443 check ssl verify none
warder
  • 138
  • 1
  • 11

1 Answers1

0

Found a solution with ansible template and Jinja2.

Variables:

---
sites:
  - domain1.com
  - domain2.com

Template:

{% for site in sites %}
backend {{ site }}
  redirect scheme https if !{ ssl_fc }
  option httpchk GET /healthcheck HTTP/1.1\r\nHost:\ {{ site }}
  default-server inter 1s fall 3 rise 2
  http-check expect ! rstatus ^5
    server server01 server01:443 check ssl verify none
    server server02 server02:443 check ssl verify none
{% endfor %}
warder
  • 138
  • 1
  • 11