ansible-role-telegraf/templates/telegraf.conf.j2

51 lines
1.5 KiB
Django/Jinja

# {{ ansible_managed }}
{% for section, options in telegraf_full_config.items() %}
[{{ section }}]
{% for option, value in options.items() %}
{{ option }} = {% if value is sameas true %}true
{% elif value is sameas false %}false
{% elif value is string %}"{{ value }}"
{% elif value is number %}{{ value }}
{% else %}["{{ value|join('", "') }}"]
{% endif %}
{% endfor %}
{% endfor %}
{% for output, options in telegraf_outputs.items() %}
[[outputs.{{ output }}]]
{% for option, value in options.items() %}
{{ option }} = {% if value is sameas true %}true
{% elif value is sameas false %}false
{% elif value is string %}"{{ value }}"
{% elif value is number %}{{ value }}
{% else %}["{{ value|join('", "') }}"]
{% endif %}
{% endfor %}
{% endfor %}
{% for input, options in telegraf_inputs.items() %}
[[inputs.{{ input }}]]
{% for option, value in options.items() %}
{% if option != 'submodule' %}
{{ option }} = {% if value is sameas true %}true
{% elif value is sameas false %}false
{% elif value is string %}"{{ value }}"
{% elif value is number %}{{ value }}
{% else %}["{{ value|join('", "') }}"]
{% endif %}
{% else %}
{% for submod in value %}
[[inputs.{{ input }}.{{ submod.name }} ]]
{% for opt, val in submod.config.items() %}
{{ opt }} = {% if val is sameas true %}true
{% elif val is sameas false %}false
{% elif val is string %}"{{ val }}"
{% elif val is number %}{{ val }}
{% else %}["{{ val|join('", "') }}"]
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}