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

109 lines
2.8 KiB
Django/Jinja

# {{ 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 %}
{% 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 %}
{% for http_error_name, config in haproxy_http_errors.items() %}
http-errors {{ http_error_name }}
{% for status_code, file in config.items() %}
errorfile {{ status_code }} /etc/haproxy/errors/{{ file }}.http
{% endfor %}
{% endfor %}
{% for userlist, config in haproxy_userlists.items() %}
userlist {{ userlist }}
{% 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 %}
{% for frontend, config in haproxy_frontends.items() %}
frontend {{ frontend }}
{% for key, value in config.items() %}
{% if key == "bind" %}
bind {{ value["ip"] }}:{{ value["port"] }}{% if value["alpn"] is defined %} alpn {{ value["alpn"] }}{% endif %}{% if value["ssl"] is defined %} ssl{% if value["ssl"]["ciphers"] is defined %} ciphers {{ value["ssl"]["ciphers"]|join(':') }}{% endif %}{% if value["ssl"]["crt"]%} crt {% if value["ssl"]["crt"] is string %}{{ value["ssl"]["crt"] }}{% else %}{{ value["ssl"]["crt"]|join(' crt ') }}{% endif %}{% endif %}
{% endif %}
{% elif value is iterable and value is not string %}
{% for option in value %}
{{ key }} {{ option }}
{% endfor %}
{% else %}
{{ key }} {{ value }}
{% endif %}
{% endfor %}
{% 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 %}