2015-02-24 16:19:02 -05:00
|
|
|
# HAProxy configuration
|
|
|
|
#
|
|
|
|
# **** DO NOT EDIT THIS FILE ****
|
|
|
|
#
|
|
|
|
# This file is managed by Salt.
|
|
|
|
# Any changes will be overwritten.
|
|
|
|
|
2015-08-17 16:40:55 -04:00
|
|
|
{%- macro render_list_of_dictionaries(name, list, indent = ' ', infix = ' ', postfix = '\t') %}
|
|
|
|
{%- if list is not iterable or list is string %}
|
|
|
|
{{ indent ~ name ~ postfix ~ list }}
|
|
|
|
{%- else %}{% for item in list %}
|
|
|
|
{%- if item is not iterable or item is string %}
|
|
|
|
{{ indent ~ name ~ postfix ~ item }}
|
|
|
|
{%- else %}{% for key, value in item.items() %}
|
|
|
|
{{- render_list_of_dictionaries(indent ~ name ~ infix ~ key, value, '', infix, postfix) }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endmacro %}
|
2015-07-23 04:46:44 -04:00
|
|
|
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# Global settings
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
global
|
|
|
|
log /dev/log local0
|
|
|
|
log /dev/log local1 notice
|
|
|
|
user {{ salt['pillar.get']('haproxy:global:user', 'haproxy') }}
|
|
|
|
group {{ salt['pillar.get']('haproxy:global:group', 'haproxy') }}
|
|
|
|
{%- if salt['pillar.get']('haproxy:global:chroot:enable', 'no') == True %}
|
|
|
|
chroot {{ salt['pillar.get']('haproxy:global:chroot:path', '/tmp') }}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if salt['pillar.get']('haproxy:global:daemon', 'no') == True %}
|
2015-02-24 16:19:02 -05:00
|
|
|
daemon
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %}
|
2015-02-24 16:19:02 -05:00
|
|
|
stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'maxconn' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
maxconn {{ salt['pillar.get']('haproxy:global:maxconn') }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'maxpipes' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
maxpipes {{ salt['pillar.get']('haproxy:global:maxpipes') }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'spreadchecks' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
spread-checks {{ salt['pillar.get']('haproxy:global:spreadchecks') }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tune' in salt['pillar.get']('haproxy:global', {}) %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('tune', salt['pillar.get']('haproxy:global:tune'), ' ','.') }}
|
2015-07-29 06:16:37 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'ssl-default-bind-ciphers' in salt['pillar.get']('haproxy:global', {}) %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('ssl-default-bind-ciphers', salt['pillar.get']('haproxy:global:ssl-default-bind-ciphers')) }}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'ssl-default-bind-options' in salt['pillar.get']('haproxy:global', {}) %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('ssl-default-bind-options', salt['pillar.get']('haproxy:global:ssl-default-bind-options')) }}
|
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# common defaults that all the 'listen' and 'backend' sections will
|
2015-07-21 11:42:56 -04:00
|
|
|
# use- if not designated in their block
|
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
defaults
|
2015-08-10 03:35:40 -04:00
|
|
|
log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }}
|
2015-07-29 06:25:43 -04:00
|
|
|
mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }}
|
|
|
|
retries {{ salt['pillar.get']('haproxy:defaults:retries', '3') }}
|
2015-07-13 19:17:06 -04:00
|
|
|
balance {{ salt['pillar.get']('haproxy:defaults:balance', 'roundrobin') }}
|
2015-08-17 16:40:55 -04:00
|
|
|
{%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) -%}
|
|
|
|
{{- render_list_of_dictionaries('option', salt['pillar.get']('haproxy:defaults:options')) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'maxconn' in salt['pillar.get']('haproxy:defaults', {}) %}
|
|
|
|
maxconn {{ salt['pillar.get']('haproxy:defaults:maxconn') }}
|
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- if 'timeouts' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- for timeout in salt['pillar.get']('haproxy:defaults:timeouts') %}
|
|
|
|
timeout {{ timeout }}
|
|
|
|
{%- endfor %}
|
2015-07-29 06:25:43 -04:00
|
|
|
{%- else %}
|
2015-08-10 03:35:40 -04:00
|
|
|
timeout client 1m
|
2015-07-29 06:25:43 -04:00
|
|
|
timeout connect 10s
|
2015-08-10 03:35:40 -04:00
|
|
|
timeout server 1m
|
2015-07-29 06:25:43 -04:00
|
|
|
{%- endif %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{%- if 'stats' in salt['pillar.get']('haproxy:defaults', {}) -%}
|
|
|
|
{{ render_list_of_dictionaries('stats', salt['pillar.get']('haproxy:defaults:stats')) }}
|
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- if 'errorfiles' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- for errorfile in salt['pillar.get']('haproxy:defaults:errorfiles').iteritems() %}
|
|
|
|
errorfile {{ errorfile[0] }} {{ errorfile[1] }}
|
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{% endif %}
|
2015-08-05 06:02:51 -04:00
|
|
|
{%- if salt['pillar.get']('haproxy:resolvers') %}
|
|
|
|
|
|
|
|
|
|
|
|
#------------------
|
|
|
|
# DNS resolvers
|
|
|
|
#------------------
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- for resolver in salt['pillar.get']('haproxy:resolvers', {}).iteritems() %}
|
2015-08-05 06:02:51 -04:00
|
|
|
resolvers {{ resolver[0] }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'options' in resolver[1] %}
|
2015-08-05 06:02:51 -04:00
|
|
|
{%- for option in resolver[1].options %}
|
|
|
|
{{ option }}
|
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
2015-08-05 06:02:51 -04:00
|
|
|
{%- endif %}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- if 'listens' in salt['pillar.get']('haproxy', {}) %}
|
|
|
|
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-07-17 22:00:32 -04:00
|
|
|
# listen instances
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- for listener in salt['pillar.get']('haproxy:listens', {}).iteritems() %}
|
2015-07-21 11:42:56 -04:00
|
|
|
listen {{ listener[1].get('name', listener[0]) }}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'bind' in listener[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if listener[1].bind is string %}
|
|
|
|
bind {{ listener[1].bind }}
|
|
|
|
{%- else %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- for socket in listener[1].bind %}
|
2015-07-17 22:00:32 -04:00
|
|
|
bind {{ socket }}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'log' in listener[1] %}
|
|
|
|
log {{ listener[1].log }}
|
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'mode' in listener[1] %}
|
|
|
|
mode {{ listener[1].mode }}
|
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'uniqueidformat' in listener[1] %}
|
|
|
|
unique-id-format {{ listener[1].uniqueidformat }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'uniqueidheader' in listener[1] %}
|
|
|
|
unique-id-header {{ listener[1].uniqueidheader }}
|
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'sticktable' in listener[1] %}
|
|
|
|
stick-table {{ listener[1].sticktable }}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'captures' in listener[1] %}
|
|
|
|
{%- if listener[1].captures is string %}
|
|
|
|
capture {{ listener[1].captures }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for capture in listener[1].captures %}
|
|
|
|
capture {{ capture }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'acls' in listener[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if listener[1].acls is string %}
|
|
|
|
acl {{ listener[1].acls }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for acl in listener[1].acls %}
|
2015-07-17 22:00:32 -04:00
|
|
|
acl {{ acl }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tcprequests' in listener[1] %}
|
|
|
|
{%- if listener[1].tcprequests is string %}
|
|
|
|
tcp-request {{ listner[1].tcprequests }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for tcprequest in listener[1].tcprequests %}
|
|
|
|
tcp-request {{ tcprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'tcpresponses' in listener[1] %}
|
|
|
|
{%- if listener[1].tcpresponses is string %}
|
|
|
|
tcp-response {{ listener[1].tcpresponses }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for tcpresponse in listener[1].tcpresponses %}
|
|
|
|
tcp-response {{ tcpresponse }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'httprequests' in listener[1] %}
|
|
|
|
{%- if listener[1].httprequests is string %}
|
|
|
|
http-request {{ listener[1].httprequests }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for httprequest in listener[1].httprequests %}
|
|
|
|
http-request {{ httprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'reqadds' in listener[1] %}
|
|
|
|
{%- if listener[1].reqadds is string %}
|
|
|
|
reqadd {{ listener[1].reqadds }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for reqadd in listener[1].reqadds %}
|
2015-07-17 22:00:32 -04:00
|
|
|
reqadd {{ reqadd }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'redirects' in listener[1] %}
|
|
|
|
{%- if listener[1].redirects is string %}
|
|
|
|
redirect {{ listener[1].redirects }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for redirect in listener[1].redirects %}
|
|
|
|
redirect {{ redirect }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'stickons' in listener[1] %}
|
|
|
|
{%- if listener[1].stickons is string %}
|
|
|
|
stick on {{ listener[1].stickons }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for stickon in listener[1].stickons %}
|
|
|
|
stick on {{ stickon }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'default_backend' in listener[1] %}
|
2015-07-17 22:00:32 -04:00
|
|
|
default_backend {{ listener[1].default_backend }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'use_backends' in listener[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if listener[1].use_backends is string %}
|
|
|
|
use_backend {{ listener[1].use_backends }}
|
|
|
|
{%- else %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{%- for use_backend in listener[1].use_backends %}
|
2015-07-17 22:00:32 -04:00
|
|
|
use_backend {{ use_backend }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'balance' in listener[1] %}
|
|
|
|
balance {{ listener[1].balance }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'maxconn' in listener[1] %}
|
|
|
|
maxconn {{ listener[1].maxconn }}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'options' in listener[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if listener[1].options is string %}
|
|
|
|
option {{ listener[1].options }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for option in listener[1].options %}
|
2015-07-17 22:00:32 -04:00
|
|
|
option {{ option }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'cookie' in listener[1] %}
|
|
|
|
cookie {{ listener[1].cookie }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'stats' in listener[1] %}
|
|
|
|
{%- for option, value in listener[1].stats.iteritems() %}
|
|
|
|
{%- if option == 'enable' and value %}
|
|
|
|
stats enable
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- else %}
|
2015-07-17 22:00:32 -04:00
|
|
|
stats {{ option }} {{ value }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'appsession' in listener[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if listener[1].appsession is string %}
|
|
|
|
appsession {{ listener[1].appsession }}
|
|
|
|
{%- else %}
|
2015-07-21 11:42:56 -04:00
|
|
|
appsession {%- for option in listener[1].appsession %} {{ option }} {%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'defaultserver' in listener[1] %}
|
|
|
|
default-server {%- for option, value in listener[1].defaultserver.iteritems() %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'servers' in listener[1] %}
|
|
|
|
{%- for server in listener[1].servers.iteritems() %}
|
2015-08-10 03:35:40 -04:00
|
|
|
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }} {{ server[1].get('extra', '') }}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- if 'frontends' in salt['pillar.get']('haproxy', {}) %}
|
2015-02-24 16:19:02 -05:00
|
|
|
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# frontend instances
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- for frontend in salt['pillar.get']('haproxy:frontends', {}).iteritems() %}
|
2015-07-21 11:42:56 -04:00
|
|
|
frontend {{ frontend[1].get('name', frontend[0]) }}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- if 'bind' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('bind', frontend[1].bind) }}
|
2015-07-17 22:00:32 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'log' in frontend[1] %}
|
|
|
|
log {{ frontend[1].log }}
|
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'mode' in frontend[1] %}
|
|
|
|
mode {{ frontend[1].mode }}
|
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'maxconn' in frontend[1] %}
|
|
|
|
maxconn {{ frontend[1].maxconn }}
|
|
|
|
{%- endif %}
|
2015-08-05 06:02:51 -04:00
|
|
|
{%- if 'options' in frontend[1] %}
|
2015-09-03 06:31:44 -04:00
|
|
|
{{- render_list_of_dictionaries('option', frontend[1].options) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'uniqueidformat' in frontend[1] %}
|
|
|
|
unique-id-format {{ frontend[1].uniqueidformat }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'uniqueidheader' in frontend[1] %}
|
|
|
|
unique-id-header {{ frontend[1].uniqueidheader }}
|
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'sticktable' in frontend[1] %}
|
|
|
|
stick-table {{ frontend[1].sticktable }}
|
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'captures' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('capture', frontend[1].captures) }}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- endif %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- if 'acls' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('acl', frontend[1].acls) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tcprequests' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('tcp-request', frontend[1].tcprequests) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tcpresponses' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('tcp-response', frontend[1].tcpresponses) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'httprequests' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('http-request', frontend[1].httprequests) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'reqadds' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('reqadd', frontend[1].reqadds) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'redirects' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('redirect', frontend[1].redirects) }}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'stickons' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('stickon', frontend[1].stickons) }}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'default_backend' in frontend[1] %}
|
2015-02-24 16:19:02 -05:00
|
|
|
default_backend {{ frontend[1].default_backend }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'use_backends' in frontend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('use_backend', frontend[1].use_backends) }}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- if 'backends' in salt['pillar.get']('haproxy', {}) %}
|
|
|
|
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# backend instances
|
2015-07-21 11:42:56 -04:00
|
|
|
#------------------
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %}
|
2015-07-21 11:42:56 -04:00
|
|
|
backend {{ backend[1].get('name',backend[0]) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'mode' in backend[1] %}
|
|
|
|
mode {{ backend[1].mode }}
|
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'balance' in backend[1] %}
|
2015-02-24 16:19:02 -05:00
|
|
|
balance {{ backend[1].balance }}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'options' in backend[1] %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if backend[1].options is string %}
|
|
|
|
option {{ backend[1].options }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for option in backend[1].options %}
|
2015-05-20 10:12:43 -04:00
|
|
|
option {{ option }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'sticktable' in backend[1] %}
|
|
|
|
stick-table {{ backend[1].sticktable }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'acls' in backend[1] %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{{- render_list_of_dictionaries('acl', backend[1].acls) }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tcprequests' in backend[1] %}
|
|
|
|
{%- if backend[1].tcprequests is string %}
|
|
|
|
tcp-request {{ backend[1].tcprequests }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for tcprequest in backend[1].tcprequests %}
|
|
|
|
tcp-request {{ tcprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'tcpresponses' in backend[1] %}
|
|
|
|
{%- if backend[1].tcpresponses is string %}
|
|
|
|
tcp-response {{ backend[1].tcpresponses }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for tcpresponse in backend[1].tcpresponses %}
|
|
|
|
tcp-response {{ tcpresponse }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'httprequests' in backend[1] %}
|
|
|
|
{%- if backend[1].httprequests is string %}
|
|
|
|
http-request {{ backend[1].httprequests }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for httprequest in backend[1].httprequests %}
|
|
|
|
http-request {{ httprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'redirects' in backend[1] %}
|
|
|
|
{%- if backend[1].redirects is string %}
|
|
|
|
redirect {{ backend[1].redirects }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for redirect in backend[1].redirects %}
|
|
|
|
redirect {{ redirect }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- if 'stickons' in backend[1] %}
|
|
|
|
{%- if backend[1].stickons is string %}
|
|
|
|
stick on {{ backend[1].stickons }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for stickon in backend[1].stickons %}
|
|
|
|
stick on {{ stickon }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'cookie' in backend[1] %}
|
2015-05-20 10:12:43 -04:00
|
|
|
cookie {{ backend[1].cookie }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'stats' in backend[1] %}
|
|
|
|
{%- for option, value in backend[1].stats.iteritems() %}
|
|
|
|
{%- if option == 'enable' and value %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats enable
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- else %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats {{ option }} {{ value }}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
2015-08-10 14:09:50 -04:00
|
|
|
{%- if 'appsession' in backend[1] %}
|
|
|
|
{%- if backend[1].appsession is string %}
|
|
|
|
appsession {{ backend[1].appsession }}
|
|
|
|
{%- else %}
|
|
|
|
appsession {%- for option in backend[1].appsession %} {{ option }} {%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-08-17 16:40:55 -04:00
|
|
|
{%- if 'reqreps' in backend[1] %}
|
|
|
|
{{- render_list_of_dictionaries('reqrep', backend[1].reqreps) }}
|
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'defaultserver' in backend[1] %}
|
|
|
|
default-server {%- for option, value in backend[1].defaultserver.iteritems() %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- if 'servers' in backend[1] %}
|
|
|
|
{%- for server in backend[1].servers.iteritems() %}
|
2015-08-05 06:02:51 -04:00
|
|
|
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }} {{ server[1].get('extra', '') }}
|
2015-07-21 11:42:56 -04:00
|
|
|
{%- endfor %}
|
2015-08-10 03:35:40 -04:00
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|
2015-07-23 04:46:44 -04:00
|
|
|
{%- endif %}
|