From ac42cac2073634cb34a2c64d407a19b0daffbfd0 Mon Sep 17 00:00:00 2001 From: Troy Germain Date: Mon, 10 Aug 2015 11:09:50 -0700 Subject: [PATCH] fixing order for warnings and adding additional options --- haproxy/templates/haproxy.jinja | 170 +++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 59 deletions(-) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index d37d047..e28ede1 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -23,18 +23,6 @@ global {%- if salt['pillar.get']('haproxy:global:stats:enable', 'no') == True %} stats socket {{ salt['pillar.get']('haproxy:global:stats:socketpath', '/tmp/ha_stats.sock') }} {%- endif %} -{%- if 'ssl-default-bind-ciphers' in salt['pillar.get']('haproxy:global', {}) %} - 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', {}) %} - {%- if salt['pillar.get']('ssl-default-bind-options') is string or salt['pillar.get']('haproxy:global:ssl-default-bind-options') is number %} - ssl-default-bind-options {{ salt['pillar.get']('haproxy:global:ssldefaultbindoptions') }} - {%- else %} - {%- for ssl-default-bind-option in salt['pillar.get']('haproxy:global:ssl-default-bind-opitions').iteritems() %} - ssl-default-bind-options {{ ssl-default-dind-option }} - {%- endfor %} - {%- endif %} -{% endif %} {%- if 'maxconn' in salt['pillar.get']('haproxy:global', {}) %} maxconn {{ salt['pillar.get']('haproxy:global:maxconn') }} {%- endif %} @@ -55,6 +43,18 @@ global {%- endif %} {%- endfor %} {%- endif %} +{%- if 'ssl-default-bind-ciphers' in salt['pillar.get']('haproxy:global', {}) %} + 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', {}) %} + {%- if salt['pillar.get']('ssl-default-bind-options') is string or salt['pillar.get']('haproxy:global:ssl-default-bind-options') is number %} + ssl-default-bind-options {{ salt['pillar.get']('haproxy:global:ssldefaultbindoptions') }} + {%- else %} + {%- for ssl-default-bind-option in salt['pillar.get']('haproxy:global:ssl-default-bind-opitions').iteritems() %} + ssl-default-bind-options {{ ssl-default-dind-option }} + {%- endfor %} + {%- endif %} +{% endif %} #------------------ # common defaults that all the 'listen' and 'backend' sections will @@ -122,12 +122,30 @@ listen {{ listener[1].get('name', listener[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'log' in listener[1] %} + log {{ listener[1].log }} + {%- endif %} {%- if 'mode' in listener[1] %} mode {{ listener[1].mode }} {%- endif %} + {%- if 'uniqueidformat' in listener[1] %} + unique-id-format {{ listener[1].uniqueidformat }} + {%- endif %} + {%- if 'uniqueidheader' in listener[1] %} + unique-id-header {{ listener[1].uniqueidheader }} + {%- endif %} {%- if 'sticktable' in listener[1] %} stick-table {{ listener[1].sticktable }} {%- endif %} + {%- if 'captures' in listener[1] %} + {%- if listener[1].captures is string %} + capture {{ listener[1].captures }} + {%- else %} + {%- for capture in listener[1].captures %} + capture {{ capture }} + {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'acls' in listener[1] %} {%- if listener[1].acls is string %} acl {{ listener[1].acls }} @@ -137,24 +155,6 @@ listen {{ listener[1].get('name', listener[0]) }} {%- endfor %} {%- endif %} {%- endif %} - {%- if 'redirects' in listener[1] %} - {%- if listener[1].redirects is string %} - redirect {{ listener[1].redirects }} - {%- else %} - {%- for redirect in listener[1].redirects %} - redirect {{ redirect }} - {%- endfor %} - {%- endif %} - {%- endif %} - {%- if 'stickons' in listener[1] %} - {%- if listener[1].stickons is string %} - stick on {{ listener[1].stickons }} - {%- else %} - {%- for stickon in listener[1].stickons %} - stick on {{ stickon }} - {%- endfor %} - {%- endif %} - {%- endif %} {%- if 'tcprequests' in listener[1] %} {%- if listener[1].tcprequests is string %} tcp-request {{ listner[1].tcprequests }} @@ -182,12 +182,6 @@ listen {{ listener[1].get('name', listener[0]) }} {%- endfor %} {%- endif %} {%- endif %} - {%- if 'uniqueidformat' in listener[1] %} - unique-id-format {{ listener[1].uniqueidformat }} - {%- endif %} - {%- if 'uniqueidheader' in listener[1] %} - unique-id-header {{ listener[1].uniqueidheader }} - {%- endif %} {%- if 'reqadds' in listener[1] %} {%- if listener[1].reqadds is string %} reqadd {{ listener[1].reqadds }} @@ -197,6 +191,24 @@ listen {{ listener[1].get('name', listener[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'redirects' in listener[1] %} + {%- if listener[1].redirects is string %} + redirect {{ listener[1].redirects }} + {%- else %} + {%- for redirect in listener[1].redirects %} + redirect {{ redirect }} + {%- endfor %} + {%- endif %} + {%- endif %} + {%- if 'stickons' in listener[1] %} + {%- if listener[1].stickons is string %} + stick on {{ listener[1].stickons }} + {%- else %} + {%- for stickon in listener[1].stickons %} + stick on {{ stickon }} + {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'default_backend' in listener[1] %} default_backend {{ listener[1].default_backend }} {%- endif %} @@ -212,6 +224,9 @@ listen {{ listener[1].get('name', listener[0]) }} {%- if 'balance' in listener[1] %} balance {{ listener[1].balance }} {%- endif %} + {%- if 'maxconn' in listener[1] %} + maxconn {{ listener[1].maxconn }} + {%- endif %} {%- if 'options' in listener[1] %} {%- if listener[1].options is string %} option {{ listener[1].options }} @@ -266,9 +281,15 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'log' in frontend[1] %} + log {{ frontend[1].log }} + {%- endif %} {%- if 'mode' in frontend[1] %} mode {{ frontend[1].mode }} {%- endif %} + {%- if 'maxconn' in frontend[1] %} + maxconn {{ frontend[1].maxconn }} + {%- endif %} {%- if 'options' in frontend[1] %} {%- if frontend[1].options is string %} option {{ frontend[1].options }} @@ -278,9 +299,24 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'uniqueidformat' in frontend[1] %} + unique-id-format {{ frontend[1].uniqueidformat }} + {%- endif %} + {%- if 'uniqueidheader' in frontend[1] %} + unique-id-header {{ frontend[1].uniqueidheader }} + {%- endif %} {%- if 'sticktable' in frontend[1] %} stick-table {{ frontend[1].sticktable }} {%- endif %} + {%- if 'captures' in frontend[1] %} + {%- if frontend[1].captures is string %} + capture {{ frontend[1].captures }} + {%- else %} + {%- for capture in frontend[1].captures %} + capture {{ capture }} + {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'acls' in frontend[1] %} {%- if frontend[1].acls is string %} acl {{ frontend[1].acls }} @@ -290,15 +326,6 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- endfor %} {%- endif %} {%- endif %} - {%- if 'redirects' in frontend[1] %} - {%- if frontend[1].redirects is string %} - redirect {{ frontend[1].redirects }} - {%- else %} - {%- for redirect in frontend[1].redirects %} - redirect {{ redirect }} - {%- endfor %} - {%- endif %} - {%- endif %} {%- if 'tcprequests' in frontend[1] %} {%- if frontend[1].tcprequests is string %} tcp-request {{ frontend[1].tcprequests }} @@ -317,12 +344,12 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- endfor %} {%- endif %} {%- endif %} - {%- if 'stickons' in frontend[1] %} - {%- if frontend[1].stickons is string %} - stick on {{ frontend[1].stickons }} + {%- if 'httprequests' in frontend[1] %} + {%- if frontend[1].httprequests is string %} + http-request {{ frontend[1].httprequests }} {%- else %} - {%- for stickon in frontend[1].stickons %} - stick on {{ stickon }} + {%- for httprequest in frontend[1].httprequests %} + http-request {{ httprequest }} {%- endfor %} {%- endif %} {%- endif %} @@ -335,6 +362,24 @@ frontend {{ frontend[1].get('name', frontend[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'redirects' in frontend[1] %} + {%- if frontend[1].redirects is string %} + redirect {{ frontend[1].redirects }} + {%- else %} + {%- for redirect in frontend[1].redirects %} + redirect {{ redirect }} + {%- endfor %} + {%- endif %} + {%- endif %} + {%- if 'stickons' in frontend[1] %} + {%- if frontend[1].stickons is string %} + stick on {{ frontend[1].stickons }} + {%- else %} + {%- for stickon in frontend[1].stickons %} + stick on {{ stickon }} + {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'default_backend' in frontend[1] %} default_backend {{ frontend[1].default_backend }} {%- endif %} @@ -383,15 +428,6 @@ backend {{ backend[1].get('name',backend[0]) }} {%- endfor %} {%- endif %} {%- endif %} - {%- if 'redirects' in backend[1] %} - {%- if backend[1].redirects is string %} - redirect {{ backend[1].redirects }} - {%- else %} - {%- for redirect in backend[1].redirects %} - redirect {{ redirect }} - {%- endfor %} - {%- endif %} - {%- endif %} {%- if 'tcprequests' in backend[1] %} {%- if backend[1].tcprequests is string %} tcp-request {{ backend[1].tcprequests }} @@ -419,6 +455,15 @@ backend {{ backend[1].get('name',backend[0]) }} {%- endfor %} {%- endif %} {%- endif %} + {%- if 'redirects' in backend[1] %} + {%- if backend[1].redirects is string %} + redirect {{ backend[1].redirects }} + {%- else %} + {%- for redirect in backend[1].redirects %} + redirect {{ redirect }} + {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'stickons' in backend[1] %} {%- if backend[1].stickons is string %} stick on {{ backend[1].stickons }} @@ -440,6 +485,13 @@ backend {{ backend[1].get('name',backend[0]) }} {%- endif %} {%- endfor %} {%- endif %} + {%- if 'appsession' in backend[1] %} + {%- if backend[1].appsession is string %} + appsession {{ backend[1].appsession }} + {%- else %} + appsession {%- for option in backend[1].appsession %} {{ option }} {%- endfor %} + {%- endif %} + {%- endif %} {%- if 'defaultserver' in backend[1] %} default-server {%- for option, value in backend[1].defaultserver.iteritems() %} {{ ' '.join((option, value|string, '')) }} {%- endfor %} {%- endif %}