paulbsd-salt/states/haproxy/map.jinja
Paul Lecuq 00c68173c9
All checks were successful
continuous-integration/drone/push Build is passing
updated haproxy state
2024-07-13 22:00:05 +02:00

33 lines
990 B
Django/Jinja

{%- import_yaml "haproxy/defaults.yaml" as defaults -%}
{%- set haproxy = salt['pillar.get']('haproxy',
default=defaults.haproxy,
merge=True) -%}
{%- set users = salt['pillar.get']('htpasswds') -%}
{%- set net = salt['pillar.get']('net') -%}
{%- set fqdn = salt['grains.get']('fqdn') -%}
{%- set country = salt['grains.get']('country') -%}
{% set peers_ip = [] %}
{%- for k,v in haproxy.peers.items() %}
{%- if k != fqdn %}
{%- for i in v %}
{% set _ = peers_ip.append([k,i]) %}
{%- endfor %}
{%- endif %}
{%- endfor %}
{% 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')}) %}