From 51b66a91ca1923992487557851f5344c0bfb93fd Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 13:16:35 +0100 Subject: [PATCH 1/6] make haproxy.cfg template more modular --- haproxy/templates/haproxy.jinja | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index adb6d52..ae2490d 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -89,13 +89,21 @@ userlist {{ id }} #------------------ defaults log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }} +{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) -%} mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }} +{%- endif %} +{%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) -%} retries {{ salt['pillar.get']('haproxy:defaults:retries', '3') }} +{%- endif %} +{%- if 'balance' in salt['pillar.get']('haproxy:defaults', {}) -%} balance {{ salt['pillar.get']('haproxy:defaults:balance', 'roundrobin') }} +{%- endif %} {%- if 'monitoruri' in salt['pillar.get']('haproxy:defaults', {}) -%} monitor-uri {{ salt['pillar.get']('haproxy:defaults:monitoruri') }} {%- endif %} +{%- if 'hashtype' in salt['pillar.get']('haproxy:defaults', {}) -%} hash-type {{ salt['pillar.get']('haproxy:defaults:hashtype', 'map-based') }} +{%- endif %} {%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) -%} {{- render_list_of_dictionaries('option', salt['pillar.get']('haproxy:defaults:options')) }} {%- endif %} From 3f3250c799b4f5f2234787206ca8f7589849128e Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 13:21:27 +0100 Subject: [PATCH 2/6] make haproxy.cfg template more modular - fix stripping --- haproxy/templates/haproxy.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index ae2490d..7c246d4 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -89,7 +89,7 @@ userlist {{ id }} #------------------ defaults log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }} -{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) -%} +{% if 'mode' in salt['pillar.get']('haproxy:defaults', {}) -%} mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }} {%- endif %} {%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) -%} From e991e668c8a34138509152d86da5952d371b88f9 Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 13:24:01 +0100 Subject: [PATCH 3/6] make haproxy.cfg template more modular - fix stripping - 2nd try --- haproxy/templates/haproxy.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index 7c246d4..132dc54 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -89,7 +89,7 @@ userlist {{ id }} #------------------ defaults log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }} -{% if 'mode' in salt['pillar.get']('haproxy:defaults', {}) -%} +{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %} mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }} {%- endif %} {%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) -%} From 97970baf84645afac1fd2190126c4c8b2a7e5441 Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 13:27:21 +0100 Subject: [PATCH 4/6] make haproxy.cfg template more modular - fix stripping - 3rd try --- haproxy/templates/haproxy.jinja | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index 132dc54..c0cee9c 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -89,7 +89,7 @@ userlist {{ id }} #------------------ defaults log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }} -{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %} +{% if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %} mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }} {%- endif %} {%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) -%} From 186be19c2731e10629239f9f81416048f67c070c Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 13:45:07 +0100 Subject: [PATCH 5/6] finally fix default section of haproxy.cfg --- haproxy/templates/haproxy.jinja | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index c0cee9c..232dd55 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -89,19 +89,19 @@ userlist {{ id }} #------------------ defaults log {{ salt['pillar.get']('haproxy:defaults:log', 'global') }} -{% if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %} +{%- if 'mode' in salt['pillar.get']('haproxy:defaults', {}) %} mode {{ salt['pillar.get']('haproxy:defaults:mode', 'http') }} {%- endif %} -{%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) -%} +{%- if 'retries' in salt['pillar.get']('haproxy:defaults', {}) %} retries {{ salt['pillar.get']('haproxy:defaults:retries', '3') }} {%- endif %} -{%- if 'balance' in salt['pillar.get']('haproxy:defaults', {}) -%} +{%- if 'balance' in salt['pillar.get']('haproxy:defaults', {}) %} balance {{ salt['pillar.get']('haproxy:defaults:balance', 'roundrobin') }} {%- endif %} -{%- if 'monitoruri' in salt['pillar.get']('haproxy:defaults', {}) -%} +{%- if 'monitoruri' in salt['pillar.get']('haproxy:defaults', {}) %} monitor-uri {{ salt['pillar.get']('haproxy:defaults:monitoruri') }} {%- endif %} -{%- if 'hashtype' in salt['pillar.get']('haproxy:defaults', {}) -%} +{%- if 'hashtype' in salt['pillar.get']('haproxy:defaults', {}) %} hash-type {{ salt['pillar.get']('haproxy:defaults:hashtype', 'map-based') }} {%- endif %} {%- if 'options' in salt['pillar.get']('haproxy:defaults', {}) -%} From 23dd429084af95f4d508973a55857ab867dfa768 Mon Sep 17 00:00:00 2001 From: hoonetorg Date: Tue, 1 Dec 2015 18:32:19 +0100 Subject: [PATCH 6/6] timeouts for listeners --- haproxy/templates/haproxy.jinja | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/haproxy/templates/haproxy.jinja b/haproxy/templates/haproxy.jinja index 232dd55..f6d5728 100644 --- a/haproxy/templates/haproxy.jinja +++ b/haproxy/templates/haproxy.jinja @@ -283,6 +283,11 @@ listen {{ listener.get('name', listener_name) }} {%- if 'maxconn' in listener %} maxconn {{ listener.maxconn }} {%- endif %} + {%- if 'timeouts' in listener %} + {%- for timeout in listener.timeouts %} + timeout {{ timeout }} + {%- endfor %} + {%- endif %} {%- if 'options' in listener %} {%- if listener.options is string %} option {{ listener.options }}