ansible-role-haproxy/templates/haproxy.cfg.j2

100 lines
2.4 KiB
Text
Raw Normal View History

2019-11-08 21:29:11 +00:00
# {{ ansible_managed }}
global
{% for key, value in haproxy_full_global.items() %}
{% if value is sameas true %}
{{ key }}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
defaults
{% for key, value in haproxy_full_defaults.items() %}
{% if value is sameas true %}
{{ key }}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
listen stats
{% for key, value in haproxy_full_listen_stats.items() %}
{% if key == "bind" %}
bind {{ value["ip"] }}:{{ value["port"] }}
{% elif value is sameas true %}
{{ key }}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
2021-08-15 11:00:28 +00:00
{% for resolver, config in haproxy_resolvers.items() %}
resolvers {{ resolver }}
{% for key, value in config.items() %}
{% if value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
{% endfor %}
2019-11-08 21:29:11 +00:00
{% for frontend, config in haproxy_frontends.items() %}
frontend {{ frontend }}
{% for key, value in config.items()|sort if key != 'acl' and key != 'use_backend' %}
{% if key == "bind" %}
bind {{ value["ip"] }}:{{ value["port"] }}{% if value["ssl"] is defined %} ssl{% if value["ssl"]["ciphers"] is defined %} ciphers {{ value["ssl"]["ciphers"]|join(':') }}{% endif %}{% if value["ssl"]["crt"]%} crt {{ value["ssl"]["crt"] }}{% endif %}
{% endif %}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
{% if 'acl' in config %}
{% for option in config['acl'] %}
acl {{ option }}
{% endfor %}
{% endif %}
{% if 'use_backend' in config %}
{% for option in config['use_backend'] %}
use_backend {{ option }}
{% endfor %}
{% endif %}
{% endfor %}
{% for backend, config in haproxy_backends.items() %}
backend {{ backend }}
{% for key, value in config.items() %}
{% if value is sameas true %}
{{ key }}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
{% endfor %}