Merge pull request #17 from sitepoint/resolvers_support

Add support for a resolvers section (new to 1.6).
This commit is contained in:
puneet kandhari 2015-08-05 11:10:45 -05:00
commit 5583754072
2 changed files with 31 additions and 1 deletions

View file

@ -59,6 +59,21 @@ defaults
errorfile {{ errorfile[0] }} {{ errorfile[1] }}
{%- endfor %}
{%- endif %}
{%- if salt['pillar.get']('haproxy:resolvers') %}
#------------------
# DNS resolvers
#------------------
{%- for resolver in salt['pillar.get']('haproxy:resolvers', {}).iteritems() %}
resolvers {{ resolver[0] }}
{%- if 'options' in resolver[1] %}
{%- for option in resolver[1].options %}
{{ option }}
{%- endfor %}
{%- endif %}
{%- endfor %}
{%- endif %}
{%- if 'listens' in salt['pillar.get']('haproxy', {}) %}
@ -153,6 +168,11 @@ frontend {{ frontend[1].get('name', frontend[0]) }}
bind {{ frontend[1].bind }}
{%- endif %}
{%- endif %}
{%- if 'options' in frontend[1] %}
{%- for option in frontend[1].options %}
{{ option }}
{%- endfor %}
{%- endif -%}
{%- if 'redirects' in frontend[1] %}
{%- for front_redirect in frontend[1].redirects %}
redirect {{ front_redirect }}
@ -216,7 +236,7 @@ backend {{ backend[1].get('name',backend[0]) }}
{%- endif %}
{%- if 'servers' in backend[1] %}
{%- for server in backend[1].servers.iteritems() %}
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }} {{ server[1].get('extra', '') }}
{%- endfor %}
{% endif %}
{%- endfor %}

View file

@ -47,6 +47,15 @@ haproxy:
503: /etc/haproxy/errors/503.http
504: /etc/haproxy/errors/504.http
{# Suported by HAProxy 1.6 #}
resolvers:
local_dns:
options:
- nameserver resolvconf 127.0.0.1:53
- resolve_retries 3
- timeout retry 1s
- hold valid 10s
listens:
stats:
bind:
@ -146,3 +155,4 @@ haproxy:
host: apiserver2.example.com
port: 80
check: check
extra: resolvers local_dns resolve-prefer ipv4