Fix typo and add some nice indentation

This commit is contained in:
John Keates 2015-05-23 19:43:21 +02:00
parent 1876b5ae35
commit cd237e0109

View file

@ -21,9 +21,9 @@ global
daemon daemon
{% endif %} {% endif %}
{%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %} {%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %}
#Stats support is currently limited to socket mode # Stats support is currently limited to socket mode
stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }} stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }}
{% endif %} {% endif %}
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will # common defaults that all the 'listen' and 'backend' sections will
@ -34,16 +34,19 @@ defaults
mode {{ salt['pillar.get']('haproxy:defaults:mode') }} mode {{ salt['pillar.get']('haproxy:defaults:mode') }}
retries {{ salt['pillar.get']('haproxy:defaults:retries') }} retries {{ salt['pillar.get']('haproxy:defaults:retries') }}
{%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) %} {%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) %}
{%- for option in salt['pillar.get']('haproxy:defaults:options') %} {%- for option in salt['pillar.get']('haproxy:defaults:options') %}
option {{ option }}{% endfor %} option {{ option }}
{%- endfor %}
{% endif %} {% endif %}
{%- if 'timeouts' in salt['pillar.get']('haproxy:defaults', {}) %} {%- if 'timeouts' in salt['pillar.get']('haproxy:defaults', {}) %}
{%- for timeout in salt['pillar.get']('haproxy:defaults:timeouts') %} {%- for timeout in salt['pillar.get']('haproxy:defaults:timeouts') %}
timeout {{ timeout }}{% endfor %} timeout {{ timeout }}
{%- endfor %}
{% 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').iteritems() %} {%- for errorfile in salt['pillar.get']('haproxy:defaults:errorfiles').iteritems() %}
errorfile {{ errorfile[0] }} {{ errorfile[1] }}{% endfor %} errorfile {{ errorfile[0] }} {{ errorfile[1] }}
{%- endfor %}
{% endif %} {% endif %}
@ -53,31 +56,31 @@ defaults
# frontend instances # frontend instances
#--------------------------------------------------------------------- #---------------------------------------------------------------------
{%- if 'frontends' in salt['pillar.get']('haproxy', {}) %} {%- if 'frontends' in salt['pillar.get']('haproxy', {}) %}
{%- for frontend in salt['pillar.get']('haproxy:frontends', {}).iteritems() %} {%- for frontend in salt['pillar.get']('haproxy:frontends', {}).iteritems() %}
frontend {{ frontend[1].name }} frontend {{ frontend[1].name }}
bind {{ frontend[1].bind }} bind {{ frontend[1].bind }}
{%- if 'redirects' in frontend[1] %} {%- if 'redirects' in frontend[1] %}
{%- for front_redirect in frontend[1].redirects %} {%- for front_redirect in frontend[1].redirects %}
redirect {{ front_redirect }} redirect {{ front_redirect }}
{% endfor %} {% endfor %}
{%- endif %} {%- endif %}
{%- if 'acls' in frontend[1] %} {%- if 'acls' in frontend[1] %}
{%- for acl in frontend[1].acls %} {%- for acl in frontend[1].acls %}
acl {{ acl }} acl {{ acl }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'reqadd' in frontend[1] %} {%- if 'reqadd' in frontend[1] %}
{%- for reqadd in frontend[1].reqadd %} {%- for reqadd in frontend[1].reqadd %}
reqadd {{ reqadd }} reqadd {{ reqadd }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
default_backend {{ frontend[1].default_backend }} default_backend {{ frontend[1].default_backend }}
{%-if 'use_backends' in frontend[1] -%} {%-if 'use_backends' in frontend[1] -%}
{%- for use_backend in frontend[1].use_backends %} {%- for use_backend in frontend[1].use_backends %}
use_backend {{ use_backend }} use_backend {{ use_backend }}
{% endfor %} {% endfor %}
{%- endif %} {%- endif %}
{% endfor %} {% endfor %}
{%- endif %} {%- endif %}
@ -85,33 +88,33 @@ redirect {{ front_redirect }}
# backend instances # backend instances
#--------------------------------------------------------------------- #---------------------------------------------------------------------
{%- if 'backends' in salt['pillar.get']('haproxy', {}) %} {%- if 'backends' in salt['pillar.get']('haproxy', {}) %}
{%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %} {%- for backend in salt['pillar.get']('haproxy:backends', {}).iteritems() %} # Backend loop start
backend {{ backend[1].name }} backend {{ backend[1].name }}
{%- if 'redirects' in backend[1] %} {%- if 'redirects' in backend[1] %}
{%- for redirect in backend[1].redirects %} {%- for redirect in backend[1].redirects %} # Redirect loop start
redirect {{ redirect }}{% endfor %} redirect {{ redirect }}{% endfor %}
{-% endif %} {%- endif %}
balance {{ backend[1].balance }} balance {{ backend[1].balance }}
{%- if 'options' in backend[1] %} {%- if 'options' in backend[1] %}
{%- for option in backend[1].options %} {%- for option in backend[1].options %}
option {{ option }} option {{ option }}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'cookie' in backend[1] %} {%- if 'cookie' in backend[1] %}
cookie {{ backend[1].cookie }} cookie {{ backend[1].cookie }}
{%- endif %} {%- endif %}
{%- if 'stats' in backend[1] %} {%- if 'stats' in backend[1] %}
{%- for option, value in backend[1].stats.iteritems() %} {%- for option, value in backend[1].stats.iteritems() %}
{%- if option == 'enable' and value %} {%- if option == 'enable' and value %}
stats enable stats enable
{%- else %} {%- else %}
stats {{ option }} {{ value }} stats {{ option }} {{ value }}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
{%- if 'servers' in backend[1] %} {%- if 'servers' in backend[1] %}
{%- for server in backend[1].servers.iteritems() %} {%- for server in backend[1].servers.iteritems() %}
server {{ server[1].name }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %} server {{ server[1].name }} {{ server[1].host }}:{{ server[1].port }} {{ server[1].check }}{% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %} # Backend loop end
{% endif %} {% endif %}