Browse Source

Adding backend recurent configuration generator

master
Pierre Coimbra 1 year ago
parent
commit
37c2c7e028
Signed by: pcoimbra GPG Key ID: F9C449C78F6FAEE6
3 changed files with 25 additions and 0 deletions
  1. +1
    -0
      defaults/main.yml
  2. +11
    -0
      templates/etc/haproxy/backend.cfg.j2
  3. +13
    -0
      templates/etc/haproxy/frontend.cfg.j2

+ 1
- 0
defaults/main.yml View File

@ -6,6 +6,7 @@ haproxy_dependencies:
- name: haproxy
state: latest
haproxy_selfca_file: /etc/ssl/haproxy/haproxy.pem
haproxy_restart_handler_state: restarted


+ 11
- 0
templates/etc/haproxy/backend.cfg.j2 View File

@ -125,3 +125,14 @@ backend {{ backend.name }}
{% endfor %}
{% endfor %}
{% for backend in backendacl | default([])%}
{% if backend.ip is defined %}
backend {{ backend.name }}
mode http
balance roundrobin
{% for server in backend.ip | default([])%}
server {{backend.name}}-{{ loop.index }} {{ server }}:443 check ssl ca-file {{ haproxy_selfca_file }}
{% endfor %}
{% endif %}
{% endfor %}

+ 13
- 0
templates/etc/haproxy/frontend.cfg.j2 View File

@ -33,8 +33,16 @@ frontend {{ frontend.name }}
timeout {{ timeout.type }} {{ timeout.timeout }}
{% endfor %}
{% for acl in frontend.acl | default([]) %}
{% if acl.string is defined %}
acl {{ acl.string }}
{% endif %}
{% endfor %}
{% if frontend.name == frontend_with_acl %}
{% for acl in backendacl | default([])%}
acl {{ acl.name }} hdr_end(host) {% if acl.domain is defined %}{% if acl.sub is defined %}{{ acl.sub }}{% else %}{{ acl.name }}{% endif %}.{{acl.domain}}{% else %}{% if acl.sub is defined %}{{ acl.sub }}{% else %}{{ acl.name }}{% endif %}.{{base_domain}}{% endif %}
{% endfor %}
{% endif %}
{% for capture in frontend.capture | default([]) %}
capture {{ capture.type }} {{ capture.name }} len {{ capture.length }}
{% endfor %}
@ -97,6 +105,11 @@ frontend {{ frontend.name }}
{% endif %}
{% endif %}
{% if frontend.name == frontend_with_acl %}
{% for backend in backendacl | default([])%}
use_backend {{ backend.name }} if {{ backend.name }}
{% endfor %}
{% endif %}
{% if frontend.default_backend is defined %}
default_backend {{ frontend.default_backend }}
{% endif %}


Loading…
Cancel
Save