updated haproxy state

This commit is contained in:
Paul 2023-09-14 16:45:28 +02:00
parent 934da68bb5
commit f6431ecd09
3 changed files with 24 additions and 3 deletions

View File

@ -36,6 +36,8 @@ haproxy:
peers:
hosts: []
port: 4096
servers:
hosts: []
dirs:
- geoip
- maps

View File

@ -19,4 +19,13 @@
{% do haproxy.config.peers.update({"hosts": peers_ip }) %}
{% set servers_ip = [] %}
{%- for k,v in haproxy.servers.items() %}
{%- for i in v %}
{% set _ = servers_ip.append([k,i]) %}
{%- endfor %}
{%- endfor %}
{% do haproxy.config.servers.update({"hosts": servers_ip }) %}
{% do haproxy.config.update({"syscontact": salt['pillar.get']('syscontact', default='anonymous@example.com')}) %}

View File

@ -24,13 +24,23 @@ http-response return status 404 content-type text/html string "<h1>404 not found
{%- macro httpendpoints(servers=[], check=True, disabled=False) -%}
{%- for server in servers %}
server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("1s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules(server.h2|default(False)) if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }}
{% if server.name in haproxy.servers.keys() -%}
{%- set addr = haproxy.servers[server.name][0] -%}
{%- else -%}
{%- set addr = server.name -%}
{%- endif -%}
server {{ server.name }} {{ addr }}:{{ server.port }}{{ " " + httpcheckrules(inter=server.inter|default("1s"), fall=server.fall|default(5), rise=server.rise|default(5)) if check }}{{ " " + httpsslrules(server.h2|default(False)) if server.ssl|default(False) }}{{ " disabled" if server.disabled|default(False) }}{{ " send-proxy" if server.proxy|default(False) }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }}
{%- endfor %}
{%- endmacro -%}
{%- macro tcpendpoints(servers=[], check=True) -%}
{%- for server in servers %}
server {{ server.name }} {{ server.name }}:{{ server.port }}{{ " check" if check }}{{ " backup" if server.backup|default(False) }} port {{ server.port }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }}
{% if server.name in haproxy.servers.keys() -%}
{%- set addr = haproxy.servers[server.name][0] -%}
{%- else -%}
{%- set addr = server.name -%}
{%- endif -%}
server {{ server.name }} {{ addr }}:{{ server.port }}{{ " check" if check }}{{ " backup" if server.backup|default(False) }} port {{ server.port }}{{ " on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions" if server.killsessions|default(False) }}
{%- endfor %}
{%- endmacro -%}