Skip to content

Commit 783878b

Browse files
committed
Support global tune parameters
1 parent 8130664 commit 783878b

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

filter_plugins/flatten.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
3+
def flatten(d, separator='.'):
4+
"""
5+
Flatten a dictionary `d` by joining nested keys with `separator`.
6+
7+
Slightly modified from <http://codereview.stackexchange.com/a/21035>.
8+
9+
>>> flatten({'eggs': 'spam', 'sausage': {'eggs': 'bacon'}, 'spam': {'bacon': {'sausage': 'spam'}}})
10+
{'spam.bacon.sausage': 'spam', 'eggs': 'spam', 'sausage.eggs': 'bacon'}
11+
"""
12+
def items():
13+
for k, v in d.items():
14+
try:
15+
for sub_k, sub_v in flatten(v, separator).items():
16+
yield separator.join([k, sub_k]), sub_v
17+
except AttributeError:
18+
yield k, v
19+
return dict(items())
20+
21+
22+
class FilterModule(object):
23+
def filters(self):
24+
return {'flatten': flatten}

templates/global.cfg

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ global
5050
{% endif -%}
5151
{% if haproxy_global.ssl_default_bind_ciphers is defined %}
5252
ssl-default-bind-ciphers {{ haproxy_global.ssl_default_bind_ciphers }}
53-
{% endif -%}
53+
{% endif -%}
54+
{% if haproxy_global.tune is defined %}
55+
{% for param, value in (haproxy_global.tune | flatten).items() -%}
56+
tune.{{ param }} {{ value }}
57+
{% endfor -%}
58+
{% endif %}

vars/main.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ empty: true
2323
# format:
2424
# ssl_default_bind_options:
2525
# ssl_default_bind_ciphers:
26+
# tune:
27+
# chksize: 32768
28+
# ssl:
29+
# default-dh-param: 2048
30+
# zlib:
31+
# memlevel: 9
2632
#
2733
#haproxy_defaults:
2834
# mode:

0 commit comments

Comments
 (0)