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-29 21:48:12 -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-02-24 16:19:02 -05:00
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# Global settings
|
2015-08-29 21:48:12 -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-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if salt['pillar.get']('haproxy:global:daemon', 'no') == True %}
|
2015-02-24 16:19:02 -05:00
|
|
|
daemon
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %}
|
2016-08-11 11:49:06 -04:00
|
|
|
stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }} mode {{ salt['pillar.get']('haproxy:global:stats:mode', '660') }} level {{ salt['pillar.get']('haproxy:global:stats:level', 'operator') }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- 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', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('tune', salt['pillar.get']('haproxy:global:tune'), ' ','.') }}
|
|
|
|
{%- endif %}
|
2015-09-07 10:30:14 -04:00
|
|
|
{%- if 'tune.ssl.default-dh-param' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('tune.ssl.default-dh-param', salt['pillar.get']('haproxy:global:tune.ssl.default-dh-param'), ' ','.') }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'ca-base' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('ca-base', salt['pillar.get']('haproxy:global:ca-base'), ' ','.') }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'crt-base' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('crt-base', salt['pillar.get']('haproxy:global:crt-base'), ' ','.') }}
|
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- if 'ssl-default-bind-ciphers' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('ssl-default-bind-ciphers', salt['pillar.get']('haproxy:global:ssl-default-bind-ciphers')) }}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'ssl-default-bind-options' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{{- render_list_of_dictionaries('ssl-default-bind-options', salt['pillar.get']('haproxy:global:ssl-default-bind-options')) }}
|
|
|
|
{%- endif %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- if 'extra' in salt['pillar.get']('haproxy:global', {}) %}
|
|
|
|
{%- if salt['pillar.get']('haproxy:global:extra', {}) is string %}
|
|
|
|
{{ salt['pillar.get']('haproxy:global:extra') }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for line in salt['pillar.get']('haproxy:global:extra') %}
|
|
|
|
{{ line }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-08-25 19:42:39 -04:00
|
|
|
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for id, userlist in salt['pillar.get']('haproxy:userlists', {})|dictsort %}
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
|
|
|
# Global Userlists
|
|
|
|
#------------------
|
2015-06-08 09:16:31 -04:00
|
|
|
userlist {{ id }}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for id, entry in userlist|dictsort %}
|
2015-06-08 10:14:28 -04:00
|
|
|
{%- if id == "groups" %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for group_name, group in entry|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
group {{ group_name }} {{ group }}
|
2015-06-08 10:14:28 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{%- if id == "users" %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for user_name, user in entry|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
user {{ user_name }} {{ user }}
|
2015-06-08 10:14:28 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{% endif %}
|
2015-06-08 09:16:31 -04:00
|
|
|
{%- endfor %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{% endfor %}
|
2015-06-08 09:16:31 -04:00
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# common defaults that all the 'listen' and 'backend' sections will
|
2015-08-29 21:48:12 -04:00
|
|
|
# use- if not designated in their block
|
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
defaults
|
2015-08-29 21:48:12 -04:00
|
|
|
log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }}
|
2015-12-01 07:45:07 -05:00
|
|
|
{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-08-29 21:48:12 -04:00
|
|
|
mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }}
|
2015-12-01 07:16:35 -05:00
|
|
|
{%- endif %}
|
2015-12-01 07:45:07 -05:00
|
|
|
{%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-08-29 21:48:12 -04:00
|
|
|
retries {{ salt['pillar.get']('haproxy:defaults:retries', '3') }}
|
2015-12-01 07:16:35 -05:00
|
|
|
{%- endif %}
|
2015-12-01 07:45:07 -05:00
|
|
|
{%- if 'balance' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-08-29 21:48:12 -04:00
|
|
|
balance {{ salt['pillar.get']('haproxy:defaults:balance', 'roundrobin') }}
|
2015-12-01 07:16:35 -05:00
|
|
|
{%- endif %}
|
2015-12-01 07:45:07 -05:00
|
|
|
{%- if 'monitoruri' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-11-06 03:57:13 -05:00
|
|
|
monitor-uri {{ salt['pillar.get']('haproxy:defaults:monitoruri') }}
|
|
|
|
{%- endif %}
|
2015-12-01 07:45:07 -05:00
|
|
|
{%- if 'hashtype' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-11-06 03:57:13 -05:00
|
|
|
hash-type {{ salt['pillar.get']('haproxy:defaults:hashtype', 'map-based') }}
|
2015-12-01 07:16:35 -05:00
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) -%}
|
|
|
|
{{- render_list_of_dictionaries('option', salt['pillar.get']('haproxy:defaults:options')) }}
|
|
|
|
{%- endif %}
|
2015-09-23 09:05:07 -04:00
|
|
|
{%- if 'logformat' in salt['pillar.get']('haproxy:defaults', {}) %}
|
|
|
|
log-format {{ salt['pillar.get']('haproxy:defaults:logformat') }}
|
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- 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-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
|
|
|
timeout client 1m
|
|
|
|
timeout connect 10s
|
|
|
|
timeout server 1m
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'stats' in salt['pillar.get']('haproxy:defaults', {}) -%}
|
|
|
|
{{ render_list_of_dictionaries('stats', salt['pillar.get']('haproxy:defaults:stats')) }}
|
|
|
|
{%- endif %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- if 'extra' in salt['pillar.get']('haproxy:defaults', {}) %}
|
|
|
|
{%- if salt['pillar.get']('haproxy:defaults:extra', {}) is string %}
|
|
|
|
{{ salt['pillar.get']('haproxy:defaults:extra') }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for line in salt['pillar.get']('haproxy:defaults:extra') %}
|
|
|
|
{{ line }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- if 'errorfiles' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for errorfile_name, errorfile in salt['pillar.get']('haproxy:defaults:errorfiles')|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
errorfile {{ errorfile_name }} {{ errorfile }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endfor %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{% endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- if salt['pillar.get']('haproxy:resolvers') %}
|
2015-02-24 16:19:02 -05:00
|
|
|
|
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
|
|
|
# DNS resolvers
|
|
|
|
#------------------
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for resolver_name, resolver in salt['pillar.get']('haproxy:resolvers', {})|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
resolvers {{ resolver_name }}
|
|
|
|
{%- if 'options' in resolver %}
|
|
|
|
{%- for option in resolver.options %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{{ option }}
|
|
|
|
{%- endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'listens' in salt['pillar.get']('haproxy', {}) %}
|
2015-07-30 18:24:58 -04:00
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
|
|
|
# listen instances
|
|
|
|
#------------------
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for listener_name, listener in salt['pillar.get']('haproxy:listens', {})|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
listen {{ listener.get('name', listener_name) }}
|
|
|
|
{%- if 'bind' in listener %}
|
|
|
|
{%- if listener.bind is string %}
|
|
|
|
bind {{ listener.bind }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for socket in listener.bind %}
|
2015-08-29 21:48:12 -04:00
|
|
|
bind {{ socket }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'log' in listener %}
|
|
|
|
log {{ listener.log }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'mode' in listener %}
|
|
|
|
mode {{ listener.mode }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'hashtype' in listener %}
|
|
|
|
hash-type {{ listener.hashtype }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'logformat' in listener %}
|
|
|
|
log-format {{ listener.logformat }}
|
2015-09-23 09:05:07 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'uniqueidformat' in listener %}
|
|
|
|
unique-id-format {{ listener.uniqueidformat }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'uniqueidheader' in listener %}
|
|
|
|
unique-id-header {{ listener.uniqueidheader }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'sticktable' in listener %}
|
|
|
|
stick-table {{ listener.sticktable }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'captures' in listener %}
|
|
|
|
{%- if listener.captures is string %}
|
|
|
|
capture {{ listener.captures }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for capture in listener.captures %}
|
2015-08-29 21:48:12 -04:00
|
|
|
capture {{ capture }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'acls' in listener %}
|
|
|
|
{%- if listener.acls is string %}
|
|
|
|
acl {{ listener.acls }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for acl in listener.acls %}
|
2015-02-24 16:19:02 -05:00
|
|
|
acl {{ acl }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'monitoruri' in listener %}
|
|
|
|
monitor-uri {{ listener.monitoruri }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'monitor' in listener %}
|
|
|
|
monitor {{ listener.monitor }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcprequests' in listener %}
|
|
|
|
{%- if listener.tcprequests is string %}
|
2016-09-28 20:38:29 -04:00
|
|
|
tcp-request {{ listener.tcprequests }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for tcprequest in listener.tcprequests %}
|
2015-08-29 21:48:12 -04:00
|
|
|
tcp-request {{ tcprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-07-30 18:14:36 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcpresponses' in listener %}
|
|
|
|
{%- if listener.tcpresponses is string %}
|
|
|
|
tcp-response {{ listener.tcpresponses }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for tcpresponse in listener.tcpresponses %}
|
2015-08-29 21:48:12 -04:00
|
|
|
tcp-response {{ tcpresponse }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httprequests' in listener %}
|
|
|
|
{%- if listener.httprequests is string %}
|
|
|
|
http-request {{ listener.httprequests }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for httprequest in listener.httprequests %}
|
2015-08-29 21:48:12 -04:00
|
|
|
http-request {{ httprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httpcheck' in listener %}
|
|
|
|
{%- if listener.httpcheck is string %}
|
|
|
|
http-check {{ listener.httpcheck }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'reqadds' in listener %}
|
|
|
|
{%- if listener.reqadds is string %}
|
|
|
|
reqadd {{ listener.reqadds }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for reqadd in listener.reqadds %}
|
2015-02-24 16:19:02 -05:00
|
|
|
reqadd {{ reqadd }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'redirects' in listener %}
|
|
|
|
{%- if listener.redirects is string %}
|
|
|
|
redirect {{ listener.redirects }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for redirect in listener.redirects %}
|
2015-08-29 21:48:12 -04:00
|
|
|
redirect {{ redirect }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'stickons' in listener %}
|
|
|
|
{%- if listener.stickons is string %}
|
|
|
|
stick on {{ listener.stickons }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for stickon in listener.stickons %}
|
2015-08-29 21:48:12 -04:00
|
|
|
stick on {{ stickon }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'default_backend' in listener %}
|
|
|
|
default_backend {{ listener.default_backend }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'use_backends' in listener %}
|
|
|
|
{%- if listener.use_backends is string %}
|
|
|
|
use_backend {{ listener.use_backends }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for use_backend in listener.use_backends %}
|
2015-08-29 21:48:12 -04:00
|
|
|
use_backend {{ use_backend }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'balance' in listener %}
|
|
|
|
balance {{ listener.balance }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'maxconn' in listener %}
|
|
|
|
maxconn {{ listener.maxconn }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-12-01 12:32:19 -05:00
|
|
|
{%- if 'timeouts' in listener %}
|
|
|
|
{%- for timeout in listener.timeouts %}
|
|
|
|
timeout {{ timeout }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'options' in listener %}
|
|
|
|
{%- if listener.options is string %}
|
|
|
|
option {{ listener.options }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for option in listener.options %}
|
2015-08-29 21:48:12 -04:00
|
|
|
option {{ option }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'cookie' in listener %}
|
|
|
|
cookie {{ listener.cookie }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'stats' in listener %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for option, value in listener.stats|dictsort %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- if option == 'enable' and value %}
|
|
|
|
stats enable
|
|
|
|
{%- else %}
|
|
|
|
stats {{ option }} {{ value }}
|
|
|
|
{%- endif %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'appsession' in listener %}
|
|
|
|
{%- if listener.appsession is string %}
|
|
|
|
appsession {{ listener.appsession }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
appsession {%- for option in listener.appsession %} {{ option }} {%- endfor %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-08-26 12:08:06 -04:00
|
|
|
{%- endif %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- if 'extra' in listener %}
|
|
|
|
{%- if listener.extra is string %}
|
|
|
|
{{ listener.extra }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for line in listerner.extra %} {{ line }} {%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'defaultserver' in listener %}
|
2015-11-24 15:43:07 -05:00
|
|
|
default-server {%- for option, value in listener.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'servers' in listener %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for server_name, server in listener.servers|dictsort %}
|
2016-06-17 16:18:48 -04:00
|
|
|
server {{ server.get('name', server_name) }} {{ server.host }}{% if 'port' in server %}:{{ server.port }}{% endif %} {% if 'maxconn' in server %} maxconn {{ server.maxconn }}{% endif %} {{ server.get('check', '') }} {{ server.get('extra', '') }}
|
2015-08-26 12:08:06 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{%- if 'frontends' in salt['pillar.get']('haproxy', {}) %}
|
2015-08-26 12:08:06 -04:00
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
|
|
|
# frontend instances
|
|
|
|
#------------------
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for frontend_name, frontend in salt['pillar.get']('haproxy:frontends', {})|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
frontend {{ frontend.get('name', frontend_name) }}
|
|
|
|
{%- if 'bind' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('bind', frontend.bind) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'log' in frontend %}
|
|
|
|
log {{ frontend.log }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'logformat' in frontend %}
|
|
|
|
log-format {{ frontend.logformat }}
|
2015-09-23 09:05:07 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'mode' in frontend %}
|
|
|
|
mode {{ frontend.mode }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'maxconn' in frontend %}
|
|
|
|
maxconn {{ frontend.maxconn }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'options' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('option', frontend.options) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'uniqueidformat' in frontend %}
|
|
|
|
unique-id-format {{ frontend.uniqueidformat }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'uniqueidheader' in frontend %}
|
2015-11-16 04:32:30 -05:00
|
|
|
unique-id-header {{ frontend.uniqueidheader }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'sticktable' in frontend %}
|
|
|
|
stick-table {{ frontend.sticktable }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'captures' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('capture', frontend.captures) }}
|
2015-08-26 12:08:06 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'acls' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('acl', frontend.acls) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-12-07 04:16:04 -05:00
|
|
|
{%- if 'blocks' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('block', frontend.blocks) }}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'monitoruri' in frontend %}
|
|
|
|
monitor-uri {{ frontend.monitoruri }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'monitor' in frontend %}
|
|
|
|
monitor {{ frontend.monitor }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcprequests' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('tcp-request', frontend.tcprequests) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcpresponses' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('tcp-response', frontend.tcpresponses) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httprequests' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('http-request', frontend.httprequests) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httpresponses' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('http-response', frontend.httpresponses) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'rspadds' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('rspadd', frontend.rspadds) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2016-02-12 17:44:36 -05:00
|
|
|
{%- if 'reqreps' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('reqrep', frontend.reqreps) }}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'reqadds' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('reqadd', frontend.reqadds) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'redirects' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('redirect', frontend.redirects) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'stickons' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('stickon', frontend.stickons) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- if 'extra' in frontend %}
|
|
|
|
{%- if frontend.extra is string %}
|
|
|
|
{{ frontend.extra }}
|
|
|
|
{%- else %}
|
|
|
|
{%- for line in frontend.extra %}
|
|
|
|
{{ line }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'default_backend' in frontend %}
|
|
|
|
default_backend {{ frontend.default_backend }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'use_backends' in frontend %}
|
|
|
|
{{- render_list_of_dictionaries('use_backend', frontend.use_backends) }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{% endif %}
|
|
|
|
{%- if 'backends' in salt['pillar.get']('haproxy', {}) %}
|
2015-02-24 16:19:02 -05:00
|
|
|
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
2015-02-24 16:19:02 -05:00
|
|
|
# backend instances
|
2015-08-29 21:48:12 -04:00
|
|
|
#------------------
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for backend_name, backend in salt['pillar.get']('haproxy:backends', {})|dictsort %}
|
2015-11-13 09:19:14 -05:00
|
|
|
backend {{ backend.get('name', backend_name) }}
|
|
|
|
{%- if 'mode' in backend %}
|
|
|
|
mode {{ backend.mode }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'hashtype' in backend %}
|
|
|
|
hash-type {{ backend.hashtype }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'balance' in backend %}
|
|
|
|
balance {{ backend.balance }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'options' in backend %}
|
|
|
|
{%- if backend.options is string %}
|
|
|
|
option {{ backend.options }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for option in backend.options %}
|
2015-05-20 10:12:43 -04:00
|
|
|
option {{ option }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'sticktable' in backend %}
|
|
|
|
stick-table {{ backend.sticktable }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'acls' in backend %}
|
|
|
|
{{- render_list_of_dictionaries('acl', backend.acls) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcprequests' in backend %}
|
|
|
|
{%- if backend.tcprequests is string %}
|
|
|
|
tcp-request {{ backend.tcprequests }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for tcprequest in backend.tcprequests %}
|
2015-08-29 21:48:12 -04:00
|
|
|
tcp-request {{ tcprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'tcpresponses' in backend %}
|
|
|
|
{%- if backend.tcpresponses is string %}
|
|
|
|
tcp-response {{ backend.tcpresponses }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for tcpresponse in backend.tcpresponses %}
|
2015-08-29 21:48:12 -04:00
|
|
|
tcp-response {{ tcpresponse }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httprequests' in backend %}
|
|
|
|
{%- if backend.httprequests is string %}
|
|
|
|
http-request {{ backend.httprequests }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for httprequest in backend.httprequests %}
|
2015-08-29 21:48:12 -04:00
|
|
|
http-request {{ httprequest }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'httpcheck' in backend %}
|
|
|
|
{%- if backend.httpcheck is string %}
|
|
|
|
http-check {{ backend.httpcheck }}
|
2015-11-06 03:57:13 -05:00
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'redirects' in backend %}
|
|
|
|
{%- if backend.redirects is string %}
|
|
|
|
redirect {{ backend.redirects }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for redirect in backend.redirects %}
|
2015-08-29 21:48:12 -04:00
|
|
|
redirect {{ redirect }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'stickons' in backend %}
|
|
|
|
{%- if backend.stickons is string %}
|
|
|
|
stick on {{ backend.stickons }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- for stickon in backend.stickons %}
|
2015-08-29 21:48:12 -04:00
|
|
|
stick on {{ stickon }}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'cookie' in backend %}
|
|
|
|
cookie {{ backend.cookie }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'stats' in backend %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for option, value in backend.stats|dictsort %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- if option == 'enable' and value %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats enable
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats {{ option }} {{ value }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'appsession' in backend %}
|
|
|
|
{%- if backend.appsession is string %}
|
|
|
|
appsession {{ backend.appsession }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- else %}
|
2015-11-13 09:19:14 -05:00
|
|
|
appsession {%- for option in backend.appsession %} {{ option }} {%- endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'reqreps' in backend %}
|
|
|
|
{{- render_list_of_dictionaries('reqrep', backend.reqreps) }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- if 'extra' in backend %}
|
|
|
|
{%- if backend.extra is string %}
|
|
|
|
{{ backend.extra }}
|
|
|
|
{%- else %}
|
2016-09-17 00:41:52 -04:00
|
|
|
{%- for line in backend.extra %}
|
|
|
|
{{ line }}
|
|
|
|
{%- endfor %}
|
2016-06-01 15:14:12 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'defaultserver' in backend %}
|
2015-11-24 15:43:07 -05:00
|
|
|
default-server {%- for option, value in backend.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endif %}
|
2015-11-13 09:19:14 -05:00
|
|
|
{%- if 'servers' in backend %}
|
2015-11-24 15:43:07 -05:00
|
|
|
{%- for server_name, server in backend.servers|dictsort %}
|
2016-01-15 04:34:05 -05:00
|
|
|
server {{ server.get('name', server_name) }} {{ server.host }}{% if 'port' in server %}:{{ server.port }}{% endif %} {{ server.get('check', '') }} {{ server.get('extra', '') }}
|
2015-08-29 21:48:12 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{%- endif %}
|