Merge pull request #34 from morsik/patch-1

Use k,v in template
This commit is contained in:
Forrest 2015-11-24 12:55:23 -08:00
commit a5bae64325

View file

@ -64,20 +64,20 @@ global
{{- render_list_of_dictionaries('ssl-default-bind-options', salt['pillar.get']('haproxy:global:ssl-default-bind-options')) }} {{- render_list_of_dictionaries('ssl-default-bind-options', salt['pillar.get']('haproxy:global:ssl-default-bind-options')) }}
{%- endif %} {%- endif %}
{%- for id, userlist in salt['pillar.get']('haproxy:userlists', {}).items() %} {%- for id, userlist in salt['pillar.get']('haproxy:userlists', {})|dictsort %}
#------------------ #------------------
# Global Userlists # Global Userlists
#------------------ #------------------
userlist {{ id }} userlist {{ id }}
{%- for id, entry in userlist.items() %} {%- for id, entry in userlist|dictsort %}
{%- if id == "groups" %} {%- if id == "groups" %}
{%- for group in entry.items() %} {%- for group_name, group in entry|dictsort %}
group {{ group[0] }} {{ group[1] }} group {{ group_name }} {{ group }}
{%- endfor %} {%- endfor %}
{% endif %} {% endif %}
{%- if id == "users" %} {%- if id == "users" %}
{%- for user in entry.items() %} {%- for user_name, user in entry|dictsort %}
user {{ user[0] }} {{ user[1] }} user {{ user_name }} {{ user }}
{%- endfor %} {%- endfor %}
{% endif %} {% endif %}
{%- endfor %} {%- endfor %}
@ -118,8 +118,8 @@ defaults
{{ render_list_of_dictionaries('stats', salt['pillar.get']('haproxy:defaults:stats')) }} {{ render_list_of_dictionaries('stats', salt['pillar.get']('haproxy:defaults:stats')) }}
{%- endif %} {%- endif %}
{%- if 'errorfiles' in salt['pillar.get']('haproxy:defaults', {}) %} {%- if 'errorfiles' in salt['pillar.get']('haproxy:defaults', {}) %}
{%- for errorfile in salt['pillar.get']('haproxy:defaults:errorfiles').items() %} {%- for errorfile_name, errorfile in salt['pillar.get']('haproxy:defaults:errorfiles')|dictsort %}
errorfile {{ errorfile[0] }} {{ errorfile[1] }} errorfile {{ errorfile_name }} {{ errorfile }}
{%- endfor %} {%- endfor %}
{% endif %} {% endif %}
{%- if salt['pillar.get']('haproxy:resolvers') %} {%- if salt['pillar.get']('haproxy:resolvers') %}
@ -128,10 +128,10 @@ defaults
#------------------ #------------------
# DNS resolvers # DNS resolvers
#------------------ #------------------
{%- for resolver in salt['pillar.get']('haproxy:resolvers', {}).items() %} {%- for resolver_name, resolver in salt['pillar.get']('haproxy:resolvers', {})|dictsort %}
resolvers {{ resolver[0] }} resolvers {{ resolver_name }}
{%- if 'options' in resolver[1] %} {%- if 'options' in resolver %}
{%- for option in resolver[1].options %} {%- for option in resolver.options %}
{{ option }} {{ option }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
@ -142,153 +142,153 @@ resolvers {{ resolver[0] }}
#------------------ #------------------
# listen instances # listen instances
#------------------ #------------------
{%- for listener in salt['pillar.get']('haproxy:listens', {}).items() %} {%- for listener_name, listener in salt['pillar.get']('haproxy:listens', {})|dictsort %}
listen {{ listener[1].get('name', listener[0]) }} listen {{ listener.get('name', listener_name) }}
{%- if 'bind' in listener[1] %} {%- if 'bind' in listener %}
{%- if listener[1].bind is string %} {%- if listener.bind is string %}
bind {{ listener[1].bind }} bind {{ listener.bind }}
{%- else %} {%- else %}
{%- for socket in listener[1].bind %} {%- for socket in listener.bind %}
bind {{ socket }} bind {{ socket }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'log' in listener[1] %} {%- if 'log' in listener %}
log {{ listener[1].log }} log {{ listener.log }}
{%- endif %} {%- endif %}
{%- if 'mode' in listener[1] %} {%- if 'mode' in listener %}
mode {{ listener[1].mode }} mode {{ listener.mode }}
{%- endif %} {%- endif %}
{%- if 'hashtype' in listener[1] %} {%- if 'hashtype' in listener %}
hash-type {{ listener[1].hashtype }} hash-type {{ listener.hashtype }}
{%- endif %} {%- endif %}
{%- if 'logformat' in listener[1] %} {%- if 'logformat' in listener %}
log-format {{ listener[1].logformat }} log-format {{ listener.logformat }}
{%- endif %} {%- endif %}
{%- if 'uniqueidformat' in listener[1] %} {%- if 'uniqueidformat' in listener %}
unique-id-format {{ listener[1].uniqueidformat }} unique-id-format {{ listener.uniqueidformat }}
{%- endif %} {%- endif %}
{%- if 'uniqueidheader' in listener[1] %} {%- if 'uniqueidheader' in listener %}
unique-id-header {{ listener[1].uniqueidheader }} unique-id-header {{ listener.uniqueidheader }}
{%- endif %} {%- endif %}
{%- if 'sticktable' in listener[1] %} {%- if 'sticktable' in listener %}
stick-table {{ listener[1].sticktable }} stick-table {{ listener.sticktable }}
{%- endif %} {%- endif %}
{%- if 'captures' in listener[1] %} {%- if 'captures' in listener %}
{%- if listener[1].captures is string %} {%- if listener.captures is string %}
capture {{ listener[1].captures }} capture {{ listener.captures }}
{%- else %} {%- else %}
{%- for capture in listener[1].captures %} {%- for capture in listener.captures %}
capture {{ capture }} capture {{ capture }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'acls' in listener[1] %} {%- if 'acls' in listener %}
{%- if listener[1].acls is string %} {%- if listener.acls is string %}
acl {{ listener[1].acls }} acl {{ listener.acls }}
{%- else %} {%- else %}
{%- for acl in listener[1].acls %} {%- for acl in listener.acls %}
acl {{ acl }} acl {{ acl }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'monitoruri' in listener[1] %} {%- if 'monitoruri' in listener %}
monitor-uri {{ listener[1].monitoruri }} monitor-uri {{ listener.monitoruri }}
{%- endif %} {%- endif %}
{%- if 'monitor' in listener[1] %} {%- if 'monitor' in listener %}
monitor {{ listener[1].monitor }} monitor {{ listener.monitor }}
{%- endif %} {%- endif %}
{%- if 'tcprequests' in listener[1] %} {%- if 'tcprequests' in listener %}
{%- if listener[1].tcprequests is string %} {%- if listener.tcprequests is string %}
tcp-request {{ listner[1].tcprequests }} tcp-request {{ listner.tcprequests }}
{%- else %} {%- else %}
{%- for tcprequest in listener[1].tcprequests %} {%- for tcprequest in listener.tcprequests %}
tcp-request {{ tcprequest }} tcp-request {{ tcprequest }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'tcpresponses' in listener[1] %} {%- if 'tcpresponses' in listener %}
{%- if listener[1].tcpresponses is string %} {%- if listener.tcpresponses is string %}
tcp-response {{ listener[1].tcpresponses }} tcp-response {{ listener.tcpresponses }}
{%- else %} {%- else %}
{%- for tcpresponse in listener[1].tcpresponses %} {%- for tcpresponse in listener.tcpresponses %}
tcp-response {{ tcpresponse }} tcp-response {{ tcpresponse }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'httprequests' in listener[1] %} {%- if 'httprequests' in listener %}
{%- if listener[1].httprequests is string %} {%- if listener.httprequests is string %}
http-request {{ listener[1].httprequests }} http-request {{ listener.httprequests }}
{%- else %} {%- else %}
{%- for httprequest in listener[1].httprequests %} {%- for httprequest in listener.httprequests %}
http-request {{ httprequest }} http-request {{ httprequest }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'httpcheck' in listener[1] %} {%- if 'httpcheck' in listener %}
{%- if listener[1].httpcheck is string %} {%- if listener.httpcheck is string %}
http-check {{ listener[1].httpcheck }} http-check {{ listener.httpcheck }}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'reqadds' in listener[1] %} {%- if 'reqadds' in listener %}
{%- if listener[1].reqadds is string %} {%- if listener.reqadds is string %}
reqadd {{ listener[1].reqadds }} reqadd {{ listener.reqadds }}
{%- else %} {%- else %}
{%- for reqadd in listener[1].reqadds %} {%- for reqadd in listener.reqadds %}
reqadd {{ reqadd }} reqadd {{ reqadd }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'redirects' in listener[1] %} {%- if 'redirects' in listener %}
{%- if listener[1].redirects is string %} {%- if listener.redirects is string %}
redirect {{ listener[1].redirects }} redirect {{ listener.redirects }}
{%- else %} {%- else %}
{%- for redirect in listener[1].redirects %} {%- for redirect in listener.redirects %}
redirect {{ redirect }} redirect {{ redirect }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'stickons' in listener[1] %} {%- if 'stickons' in listener %}
{%- if listener[1].stickons is string %} {%- if listener.stickons is string %}
stick on {{ listener[1].stickons }} stick on {{ listener.stickons }}
{%- else %} {%- else %}
{%- for stickon in listener[1].stickons %} {%- for stickon in listener.stickons %}
stick on {{ stickon }} stick on {{ stickon }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'default_backend' in listener[1] %} {%- if 'default_backend' in listener %}
default_backend {{ listener[1].default_backend }} default_backend {{ listener.default_backend }}
{%- endif %} {%- endif %}
{%- if 'use_backends' in listener[1] %} {%- if 'use_backends' in listener %}
{%- if listener[1].use_backends is string %} {%- if listener.use_backends is string %}
use_backend {{ listener[1].use_backends }} use_backend {{ listener.use_backends }}
{%- else %} {%- else %}
{%- for use_backend in listener[1].use_backends %} {%- for use_backend in listener.use_backends %}
use_backend {{ use_backend }} use_backend {{ use_backend }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'balance' in listener[1] %} {%- if 'balance' in listener %}
balance {{ listener[1].balance }} balance {{ listener.balance }}
{%- endif %} {%- endif %}
{%- if 'maxconn' in listener[1] %} {%- if 'maxconn' in listener %}
maxconn {{ listener[1].maxconn }} maxconn {{ listener.maxconn }}
{%- endif %} {%- endif %}
{%- if 'options' in listener[1] %} {%- if 'options' in listener %}
{%- if listener[1].options is string %} {%- if listener.options is string %}
option {{ listener[1].options }} option {{ listener.options }}
{%- else %} {%- else %}
{%- for option in listener[1].options %} {%- for option in listener.options %}
option {{ option }} option {{ option }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'cookie' in listener[1] %} {%- if 'cookie' in listener %}
cookie {{ listener[1].cookie }} cookie {{ listener.cookie }}
{%- endif %} {%- endif %}
{%- if 'stats' in listener[1] %} {%- if 'stats' in listener %}
{%- for option, value in listener[1].stats.items() %} {%- for option, value in listener.stats|dictsort %}
{%- if option == 'enable' and value %} {%- if option == 'enable' and value %}
stats enable stats enable
{%- else %} {%- else %}
@ -296,19 +296,19 @@ listen {{ listener[1].get('name', listener[0]) }}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'appsession' in listener[1] %} {%- if 'appsession' in listener %}
{%- if listener[1].appsession is string %} {%- if listener.appsession is string %}
appsession {{ listener[1].appsession }} appsession {{ listener.appsession }}
{%- else %} {%- else %}
appsession {%- for option in listener[1].appsession %} {{ option }} {%- endfor %} appsession {%- for option in listener.appsession %} {{ option }} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'defaultserver' in listener[1] %} {%- if 'defaultserver' in listener %}
default-server {%- for option, value in listener[1].defaultserver.items() %} {{ ' '.join((option, value|string, '')) }} {%- endfor %} default-server {%- for option, value in listener.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'servers' in listener[1] %} {%- if 'servers' in listener %}
{%- for server in listener[1].servers.items()|sort %} {%- for server_name, server in listener.servers|dictsort %}
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }} {{ server[1].get('extra', '') }} server {{ server.get('name', server_name) }} {{ server.host }}:{{ server.port }} {{ server.check }} {{ server.get('extra', '') }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{% endfor %} {% endfor %}
@ -318,76 +318,76 @@ listen {{ listener[1].get('name', listener[0]) }}
#------------------ #------------------
# frontend instances # frontend instances
#------------------ #------------------
{%- for frontend in salt['pillar.get']('haproxy:frontends', {}).items() %} {%- for frontend_name, frontend in salt['pillar.get']('haproxy:frontends', {})|dictsort %}
frontend {{ frontend[1].get('name', frontend[0]) }} frontend {{ frontend.get('name', frontend_name) }}
{%- if 'bind' in frontend[1] %} {%- if 'bind' in frontend %}
{{- render_list_of_dictionaries('bind', frontend[1].bind) }} {{- render_list_of_dictionaries('bind', frontend.bind) }}
{%- endif %} {%- endif %}
{%- if 'log' in frontend[1] %} {%- if 'log' in frontend %}
log {{ frontend[1].log }} log {{ frontend.log }}
{%- endif %} {%- endif %}
{%- if 'logformat' in frontend[1] %} {%- if 'logformat' in frontend %}
log-format {{ frontend[1].logformat }} log-format {{ frontend.logformat }}
{%- endif %} {%- endif %}
{%- if 'mode' in frontend[1] %} {%- if 'mode' in frontend %}
mode {{ frontend[1].mode }} mode {{ frontend.mode }}
{%- endif %} {%- endif %}
{%- if 'maxconn' in frontend[1] %} {%- if 'maxconn' in frontend %}
maxconn {{ frontend[1].maxconn }} maxconn {{ frontend.maxconn }}
{%- endif %} {%- endif %}
{%- if 'options' in frontend[1] %} {%- if 'options' in frontend %}
{{- render_list_of_dictionaries('option', frontend[1].options) }} {{- render_list_of_dictionaries('option', frontend.options) }}
{%- endif %} {%- endif %}
{%- if 'uniqueidformat' in frontend[1] %} {%- if 'uniqueidformat' in frontend %}
unique-id-format {{ frontend[1].uniqueidformat }} unique-id-format {{ frontend.uniqueidformat }}
{%- endif %} {%- endif %}
{%- if 'uniqueidheader' in frontend[1] %} {%- if 'uniqueidheader' in frontend %}
unique-id-header {{ frontend[1].uniqueidheader }} unique-id-header {{ frontend.uniqueidheader }}
{%- endif %} {%- endif %}
{%- if 'sticktable' in frontend[1] %} {%- if 'sticktable' in frontend %}
stick-table {{ frontend[1].sticktable }} stick-table {{ frontend.sticktable }}
{%- endif %} {%- endif %}
{%- if 'captures' in frontend[1] %} {%- if 'captures' in frontend %}
{{- render_list_of_dictionaries('capture', frontend[1].captures) }} {{- render_list_of_dictionaries('capture', frontend.captures) }}
{%- endif %} {%- endif %}
{%- if 'acls' in frontend[1] %} {%- if 'acls' in frontend %}
{{- render_list_of_dictionaries('acl', frontend[1].acls) }} {{- render_list_of_dictionaries('acl', frontend.acls) }}
{%- endif %} {%- endif %}
{%- if 'monitoruri' in frontend[1] %} {%- if 'monitoruri' in frontend %}
monitor-uri {{ frontend[1].monitoruri }} monitor-uri {{ frontend.monitoruri }}
{%- endif %} {%- endif %}
{%- if 'monitor' in frontend[1] %} {%- if 'monitor' in frontend %}
monitor {{ frontend[1].monitor }} monitor {{ frontend.monitor }}
{%- endif %} {%- endif %}
{%- if 'tcprequests' in frontend[1] %} {%- if 'tcprequests' in frontend %}
{{- render_list_of_dictionaries('tcp-request', frontend[1].tcprequests) }} {{- render_list_of_dictionaries('tcp-request', frontend.tcprequests) }}
{%- endif %} {%- endif %}
{%- if 'tcpresponses' in frontend[1] %} {%- if 'tcpresponses' in frontend %}
{{- render_list_of_dictionaries('tcp-response', frontend[1].tcpresponses) }} {{- render_list_of_dictionaries('tcp-response', frontend.tcpresponses) }}
{%- endif %} {%- endif %}
{%- if 'httprequests' in frontend[1] %} {%- if 'httprequests' in frontend %}
{{- render_list_of_dictionaries('http-request', frontend[1].httprequests) }} {{- render_list_of_dictionaries('http-request', frontend.httprequests) }}
{%- endif %} {%- endif %}
{%- if 'httpresponses' in frontend[1] %} {%- if 'httpresponses' in frontend %}
{{- render_list_of_dictionaries('http-response', frontend[1].httpresponses) }} {{- render_list_of_dictionaries('http-response', frontend.httpresponses) }}
{%- endif %} {%- endif %}
{%- if 'rspadds' in frontend[1] %} {%- if 'rspadds' in frontend %}
{{- render_list_of_dictionaries('rspadd', frontend[1].rspadds) }} {{- render_list_of_dictionaries('rspadd', frontend.rspadds) }}
{%- endif %} {%- endif %}
{%- if 'reqadds' in frontend[1] %} {%- if 'reqadds' in frontend %}
{{- render_list_of_dictionaries('reqadd', frontend[1].reqadds) }} {{- render_list_of_dictionaries('reqadd', frontend.reqadds) }}
{%- endif %} {%- endif %}
{%- if 'redirects' in frontend[1] %} {%- if 'redirects' in frontend %}
{{- render_list_of_dictionaries('redirect', frontend[1].redirects) }} {{- render_list_of_dictionaries('redirect', frontend.redirects) }}
{%- endif %} {%- endif %}
{%- if 'stickons' in frontend[1] %} {%- if 'stickons' in frontend %}
{{- render_list_of_dictionaries('stickon', frontend[1].stickons) }} {{- render_list_of_dictionaries('stickon', frontend.stickons) }}
{%- endif %} {%- endif %}
{%- if 'default_backend' in frontend[1] %} {%- if 'default_backend' in frontend %}
default_backend {{ frontend[1].default_backend }} default_backend {{ frontend.default_backend }}
{%- endif %} {%- endif %}
{%- if 'use_backends' in frontend[1] %} {%- if 'use_backends' in frontend %}
{{- render_list_of_dictionaries('use_backend', frontend[1].use_backends) }} {{- render_list_of_dictionaries('use_backend', frontend.use_backends) }}
{%- endif %} {%- endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -396,87 +396,87 @@ frontend {{ frontend[1].get('name', frontend[0]) }}
#------------------ #------------------
# backend instances # backend instances
#------------------ #------------------
{%- for backend in salt['pillar.get']('haproxy:backends', {}).items() %} {%- for backend_name, backend in salt['pillar.get']('haproxy:backends', {})|dictsort %}
backend {{ backend[1].get('name',backend[0]) }} backend {{ backend.get('name', backend_name) }}
{%- if 'mode' in backend[1] %} {%- if 'mode' in backend %}
mode {{ backend[1].mode }} mode {{ backend.mode }}
{%- endif %} {%- endif %}
{%- if 'hashtype' in backend[1] %} {%- if 'hashtype' in backend %}
hash-type {{ backend[1].hashtype }} hash-type {{ backend.hashtype }}
{%- endif %} {%- endif %}
{%- if 'balance' in backend[1] %} {%- if 'balance' in backend %}
balance {{ backend[1].balance }} balance {{ backend.balance }}
{%- endif %} {%- endif %}
{%- if 'options' in backend[1] %} {%- if 'options' in backend %}
{%- if backend[1].options is string %} {%- if backend.options is string %}
option {{ backend[1].options }} option {{ backend.options }}
{%- else %} {%- else %}
{%- for option in backend[1].options %} {%- for option in backend.options %}
option {{ option }} option {{ option }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'sticktable' in backend[1] %} {%- if 'sticktable' in backend %}
stick-table {{ backend[1].sticktable }} stick-table {{ backend.sticktable }}
{%- endif %} {%- endif %}
{%- if 'acls' in backend[1] %} {%- if 'acls' in backend %}
{{- render_list_of_dictionaries('acl', backend[1].acls) }} {{- render_list_of_dictionaries('acl', backend.acls) }}
{%- endif %} {%- endif %}
{%- if 'tcprequests' in backend[1] %} {%- if 'tcprequests' in backend %}
{%- if backend[1].tcprequests is string %} {%- if backend.tcprequests is string %}
tcp-request {{ backend[1].tcprequests }} tcp-request {{ backend.tcprequests }}
{%- else %} {%- else %}
{%- for tcprequest in backend[1].tcprequests %} {%- for tcprequest in backend.tcprequests %}
tcp-request {{ tcprequest }} tcp-request {{ tcprequest }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'tcpresponses' in backend[1] %} {%- if 'tcpresponses' in backend %}
{%- if backend[1].tcpresponses is string %} {%- if backend.tcpresponses is string %}
tcp-response {{ backend[1].tcpresponses }} tcp-response {{ backend.tcpresponses }}
{%- else %} {%- else %}
{%- for tcpresponse in backend[1].tcpresponses %} {%- for tcpresponse in backend.tcpresponses %}
tcp-response {{ tcpresponse }} tcp-response {{ tcpresponse }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'httprequests' in backend[1] %} {%- if 'httprequests' in backend %}
{%- if backend[1].httprequests is string %} {%- if backend.httprequests is string %}
http-request {{ backend[1].httprequests }} http-request {{ backend.httprequests }}
{%- else %} {%- else %}
{%- for httprequest in backend[1].httprequests %} {%- for httprequest in backend.httprequests %}
http-request {{ httprequest }} http-request {{ httprequest }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'httpcheck' in backend[1] %} {%- if 'httpcheck' in backend %}
{%- if backend[1].httpcheck is string %} {%- if backend.httpcheck is string %}
http-check {{ backend[1].httpcheck }} http-check {{ backend.httpcheck }}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'redirects' in backend[1] %} {%- if 'redirects' in backend %}
{%- if backend[1].redirects is string %} {%- if backend.redirects is string %}
redirect {{ backend[1].redirects }} redirect {{ backend.redirects }}
{%- else %} {%- else %}
{%- for redirect in backend[1].redirects %} {%- for redirect in backend.redirects %}
redirect {{ redirect }} redirect {{ redirect }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'stickons' in backend[1] %} {%- if 'stickons' in backend %}
{%- if backend[1].stickons is string %} {%- if backend.stickons is string %}
stick on {{ backend[1].stickons }} stick on {{ backend.stickons }}
{%- else %} {%- else %}
{%- for stickon in backend[1].stickons %} {%- for stickon in backend.stickons %}
stick on {{ stickon }} stick on {{ stickon }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'cookie' in backend[1] %} {%- if 'cookie' in backend %}
cookie {{ backend[1].cookie }} cookie {{ backend.cookie }}
{%- endif %} {%- endif %}
{%- if 'stats' in backend[1] %} {%- if 'stats' in backend %}
{%- for option, value in backend[1].stats.items() %} {%- for option, value in backend.stats|dictsort %}
{%- if option == 'enable' and value %} {%- if option == 'enable' and value %}
stats enable stats enable
{%- else %} {%- else %}
@ -484,22 +484,22 @@ backend {{ backend[1].get('name',backend[0]) }}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'appsession' in backend[1] %} {%- if 'appsession' in backend %}
{%- if backend[1].appsession is string %} {%- if backend.appsession is string %}
appsession {{ backend[1].appsession }} appsession {{ backend.appsession }}
{%- else %} {%- else %}
appsession {%- for option in backend[1].appsession %} {{ option }} {%- endfor %} appsession {%- for option in backend.appsession %} {{ option }} {%- endfor %}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- if 'reqreps' in backend[1] %} {%- if 'reqreps' in backend %}
{{- render_list_of_dictionaries('reqrep', backend[1].reqreps) }} {{- render_list_of_dictionaries('reqrep', backend.reqreps) }}
{%- endif %} {%- endif %}
{%- if 'defaultserver' in backend[1] %} {%- if 'defaultserver' in backend %}
default-server {%- for option, value in backend[1].defaultserver.items() %} {{ ' '.join((option, value|string, '')) }} {%- endfor %} default-server {%- for option, value in backend.defaultserver|dictsort %} {{ ' '.join((option, value|string, '')) }} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'servers' in backend[1] %} {%- if 'servers' in backend %}
{%- for server in backend[1].servers.items()|sort %} {%- for server_name, server in backend.servers|dictsort %}
server {{ server[1].get('name',server[0]) }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }} {{ server[1].get('extra', '') }} server {{ server.get('name', server_name) }} {{ server.host }}:{{ server.port }} {{ server.check }} {{ server.get('extra', '') }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{% endfor %} {% endfor %}