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.
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# Global settings
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
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') }}
|
|
|
|
{%- endif -%}
|
|
|
|
{% if salt['pillar.get']('haproxy:global:daemon', 'no') == True %}
|
|
|
|
daemon
|
|
|
|
{% endif %}
|
|
|
|
{%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %}
|
2015-05-23 13:43:21 -04:00
|
|
|
# Stats support is currently limited to socket mode
|
2015-02-24 16:19:02 -05:00
|
|
|
stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{% endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
|
2015-06-08 09:16:31 -04:00
|
|
|
{%- for id, userlist in salt['pillar.get']('haproxy:userlists', {}).iteritems() %}
|
|
|
|
userlist {{ id }}
|
2015-06-08 10:14:28 -04:00
|
|
|
{%- for id, entry in userlist.iteritems() %}
|
|
|
|
{%- if id == "groups" %}
|
|
|
|
{%- for group in entry.iteritems() %}
|
|
|
|
group {{ group[0] }} {{ group[1] }}
|
|
|
|
{%- endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{%- if id == "users" %}
|
|
|
|
{%- for user in entry.iteritems() %}
|
|
|
|
user {{ user[0] }} {{ user[1] }}
|
|
|
|
{%- endfor %}
|
|
|
|
{% endif %}
|
2015-06-08 09:16:31 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{% endfor %}
|
|
|
|
|
|
|
|
|
2015-06-08 10:14:28 -04:00
|
|
|
|
2015-02-24 16:19:02 -05:00
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# common defaults that all the 'listen' and 'backend' sections will
|
|
|
|
# use if not designated in their block
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
defaults
|
|
|
|
log {{ salt['pillar.get']('haproxy:defaults:log') }}
|
|
|
|
mode {{ salt['pillar.get']('haproxy:defaults:mode') }}
|
|
|
|
retries {{ salt['pillar.get']('haproxy:defaults:retries') }}
|
|
|
|
{%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- for option in salt['pillar.get']('haproxy:defaults:options') %}
|
|
|
|
option {{ option }}
|
|
|
|
{%- endfor %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{% endif %}
|
|
|
|
{%- 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-02-24 16:19:02 -05:00
|
|
|
{% endif %}
|
|
|
|
{%- 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-02-24 16:19:02 -05:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# frontend instances
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
{%- if 'frontends' in salt['pillar.get']('haproxy', {}) %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- for frontend in salt['pillar.get']('haproxy:frontends', {}).iteritems() %}
|
2015-02-26 08:34:47 -05:00
|
|
|
frontend {{ frontend[1].name }}
|
|
|
|
bind {{ frontend[1].bind }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- if 'redirects' in frontend[1] %}
|
|
|
|
{%- for front_redirect in frontend[1].redirects %}
|
2015-05-17 12:26:08 -04:00
|
|
|
redirect {{ front_redirect }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{% endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'acls' in frontend[1] %}
|
|
|
|
{%- for acl in frontend[1].acls %}
|
2015-02-24 16:19:02 -05:00
|
|
|
acl {{ acl }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{%- if 'reqadd' in frontend[1] %}
|
|
|
|
{%- for reqadd in frontend[1].reqadd %}
|
2015-02-24 16:19:02 -05:00
|
|
|
reqadd {{ reqadd }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endfor %}
|
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
default_backend {{ frontend[1].default_backend }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%-if 'use_backends' in frontend[1] -%}
|
|
|
|
{%- for use_backend in frontend[1].use_backends %}
|
2015-02-24 16:19:02 -05:00
|
|
|
use_backend {{ use_backend }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{% endfor %}
|
|
|
|
{%- endif %}
|
|
|
|
{% endfor %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- endif %}
|
|
|
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
# backend instances
|
|
|
|
#---------------------------------------------------------------------
|
|
|
|
{%- if 'backends' in salt['pillar.get']('haproxy', {}) %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %} # Backend loop start
|
2015-02-24 16:19:02 -05:00
|
|
|
backend {{ backend[1].name }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- if 'redirects' in backend[1] %}
|
|
|
|
{%- for redirect in backend[1].redirects %} # Redirect loop start
|
2015-05-17 09:47:47 -04:00
|
|
|
redirect {{ redirect }}{% endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
2015-02-24 16:19:02 -05:00
|
|
|
balance {{ backend[1].balance }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- if 'options' in backend[1] %}
|
2015-05-20 10:12:43 -04:00
|
|
|
{%- for option in backend[1].options %}
|
|
|
|
option {{ option }}
|
|
|
|
{%- endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'cookie' in backend[1] %}
|
2015-05-20 10:12:43 -04:00
|
|
|
cookie {{ backend[1].cookie }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'stats' in backend[1] %}
|
2015-05-20 10:12:43 -04:00
|
|
|
{%- for option, value in backend[1].stats.iteritems() %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- if option == 'enable' and value %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats enable
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- else %}
|
2015-05-20 10:12:43 -04:00
|
|
|
stats {{ option }} {{ value }}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
2015-05-20 10:12:43 -04:00
|
|
|
{%- endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{%- endif %}
|
|
|
|
{%- if 'servers' in backend[1] %}
|
2015-02-24 16:19:02 -05:00
|
|
|
{%- for server in backend[1].servers.iteritems() %}
|
|
|
|
server {{ server[1].name }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %}
|
2015-05-23 13:43:21 -04:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %} # Backend loop end
|
2015-05-17 09:47:47 -04:00
|
|
|
{% endif %}
|