From f8375f323cd471851e6ac78e8af7f1ff52afed30 Mon Sep 17 00:00:00 2001 From: psy Date: Fri, 15 Jan 2021 12:37:08 +0100 Subject: [PATCH] try to parse lists and dicts from config --- templates/local.d.config.j2 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/templates/local.d.config.j2 b/templates/local.d.config.j2 index fc6c9db..333e9e2 100644 --- a/templates/local.d.config.j2 +++ b/templates/local.d.config.j2 @@ -1,4 +1,18 @@ +{%- macro keyvalue(key, value, depth=0) -%} +{%- if value is string -%} +{{ key }}="{{ value }}"; +{%- elif value is mapping %} +{{ key }} { + {% for key, value in value.items() %} + {{ keyvalue(key, value) }} + {% endfor %} +} +{% elif value is iterable and (value is not string and value is not mapping) -%} +{{ key }}=["{{ value|join('", "') }}"]; +{%- endif -%} +{%- endmacro -%} + # {{ ansible_managed }} {% for key, value in item.value.items() %} -{{ key }}="{{ value }}"; +{{ keyvalue(key, value) }} {% endfor %}