diff --git a/states/haproxy/templates/haproxy.cfg.j2 b/states/haproxy/templates/haproxy.cfg.j2
index e7c6719..708d237 100644
--- a/states/haproxy/templates/haproxy.cfg.j2
+++ b/states/haproxy/templates/haproxy.cfg.j2
@@ -25,7 +25,9 @@ http-response return status 404 content-type text/html string "
404 not found
{%- macro httpendpoints(servers=[], check=True, disabled=False) -%}
{%- if servers -%}
{%- for server in servers %}
- {% if server.name in haproxy.servers.keys() -%}
+ {% if "addr" in server.keys() -%}
+ {%- set addr = server.addr -%}
+ {%- elif server.name in haproxy.servers.keys() -%}
{%- set addr = haproxy.servers[server.name][0] -%}
{%- else -%}
{%- set addr = server.name -%}
@@ -38,12 +40,14 @@ http-response return status 404 content-type text/html string "404 not found
{%- macro tcpendpoints(servers=[], check=True) -%}
{%- if servers -%}
{%- for server in servers %}
- {% if server.name in haproxy.servers.keys() -%}
+ {% if "addr" in server.keys() -%}
+ {%- set addr = server.addr -%}
+ {%- elif 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) }}
+ server {{ server.name }} {{ addr }}:{{ server.port }}{{ " check" if check }}{{ " backup" if server.backup|default(False) }} port {{ server.port }}{{ " on-marked-down shutdown-sessions" if server.killsessions|default(False) }}
{%- endfor %}
{%- endif -%}
{%- endmacro -%}
@@ -290,6 +294,8 @@ listen {{ name }} from {{ haproxy.config.namespace }}
mode tcp
option tcplog
option tcpka
+ stick-table type ip size 10k peers paulbsd
+ stick on dst
{%- if values.type == "postgres" %}
option pgsql-check user repmgr
{%- endif %}