From fd66f704fdc30b2d765805184e7c8e7a30717043 Mon Sep 17 00:00:00 2001 From: jvblasco Date: Wed, 20 May 2015 16:12:43 +0200 Subject: [PATCH] Add support for option, cookie and stats tags in backend instances --- haproxy/templates/haproxy.jinja | 17 +++++++++++++++++ pillar.example | 12 ++++++++++++ 2 files changed, 29 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index c70203c..03a3b40 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -83,6 +83,23 @@ frontend {{ frontend[1].name }} {%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %} backend {{ backend[1].name }} balance {{ backend[1].balance }} + {%- if 'options' in backend[1] %} + {%- for option in backend[1].options %} + option {{ option }} + {%- endfor %} + {%- endif %} + {%- if 'cookie' in backend[1] %} + cookie {{ backend[1].cookie }} + {%- endif %} + {%- if 'stats' in backend[1] %} + {%- for option, value in backend[1].stats.iteritems() %} + {%- if option == 'enable' and value %} + stats enable + {%- else %} + stats {{ option }} {{ value }} + {%- endif %} + {%- endfor %} + {%- endif %} {%- if 'servers' in backend[1] %} {%- for server in backend[1].servers.iteritems() %} server {{ server[1].name }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %} diff --git a/pillar.example b/pillar.example index 137b9de..2abd558 100644 --- a/pillar.example +++ b/pillar.example @@ -73,11 +73,23 @@ haproxy: server1: name: server1-its-name host: 192.168.1.213 + port: 80 check: check backend2: name: static balance: roundrobin redirect: scheme https if !{ ssl_fc } + options: + - http-server-close + - httpclose + - forwardfor except 127.0.0.0/8 + - httplog + cookie: "pm insert indirect" + stats: + enable: True + uri: /url/to/stats + realm: LoadBalancer + auth: "user:password" servers: server1: name: some-server