From 5ee366fd685f9fb4cc67439442671ee53bd0131a Mon Sep 17 00:00:00 2001 From: Paul Lecuq Date: Tue, 28 Jun 2022 23:21:35 +0200 Subject: [PATCH] updated telegraf state --- states/telegraf/telegraf.conf.j2 | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/states/telegraf/telegraf.conf.j2 b/states/telegraf/telegraf.conf.j2 index 1dc1f6a..e76b3fb 100644 --- a/states/telegraf/telegraf.conf.j2 +++ b/states/telegraf/telegraf.conf.j2 @@ -1,5 +1,12 @@ ## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }} {%- from "telegraf/map.jinja" import telegraf with context %} +{% macro cfg(value) -%} +{% if value is not none -%} +{% for paramname, paramvalue in value.items() -%} +{{ ' ' }}{{ paramname }} = {% if paramvalue is sameas True or paramvalue is sameas False %}{{ paramvalue|string|lower }}{% elif paramvalue is iterable and paramvalue is not string %}[{{ paramvalue|join(",") }}]{% else %}"{{ paramvalue }}"{% endif %} +{% endfor %} +{%- endif %} +{%- endmacro %} [global_tags] [agent] interval = "1m" @@ -15,18 +22,10 @@ {% for name, value in telegraf.config.outputs.items() -%} [[outputs.{{ name }}]] -{% if value is not none -%} -{% for paramname, paramvalue in value.items() -%} -{{ ' '}}{{ paramname }} = {% if paramvalue is sameas True or paramvalue is sameas False %}{{ paramvalue|string|lower }}{% elif paramvalue is iterable and paramvalue is not string %}[{{ paramvalue|join(",") }}]{% else %}"{{ paramvalue }}"{% endif %} -{% endfor %} -{%- endif %} +{{ cfg(value) }} {% endfor %} {% for name, value in telegraf.config.inputs.items() -%} [[inputs.{{ name }}]] -{% if value is not none -%} -{% for paramname, paramvalue in value.items() -%} -{{ ' ' }}{{ paramname }} = {% if paramvalue is sameas True or paramvalue is sameas False %}{{ paramvalue|string|lower }}{% elif paramvalue is iterable and paramvalue is not string %}[{{ paramvalue|join(",") }}]{% else %}"{{ paramvalue }}"{% endif %} -{% endfor %} -{%- endif %} +{{ cfg(value) }} {% endfor -%}