ansible/roles/telegraf/templates/telegraf.conf.j2

97 lines
2.2 KiB
Plaintext
Raw Normal View History

2019-10-27 23:33:06 +00:00
# {{ ansible_managed }}
{% macro toml_scalar(v, seq=False) %}
{% if v is string %}
"{{ v | quote }}"{% if seq %},{% endif %}
{% elif v is sameas True or v is sameas False %}
{{ v | bool | lower }}{% if seq %},{% endif %}
{% elif v is sameas None %}
""{% if seq %},{% endif %}
{% elif v is number %}
{{ v }}{% if seq %},{% endif %}
{% endif %}
{% endmacro %}
{% if telegraf_config_global_tags %}
[global_tags]
{% for k, v in telegraf_config_global_tags.items() | default({}) %}
{% if v is string %}
{{ k }} = "{{ v | quote }}"
{% elif v is sameas True or v is sameas False %}
{{ k }} = {{ v | bool | lower }}
{% elif v is sameas None %}
{{ k }} = ""
{% else %}
{{ k }} = {{ v }}
{% endif %}
{% endfor %}
{% endif %}
{% if telegraf_config_agent %}
[agent]
{% for k, v in telegraf_config_agent.items() | default({}) %}
{% if v is string %}
{{ k }} = "{{ v | quote }}"
{% elif v is sameas True or v is sameas False %}
{{ k }} = {{ v | bool | lower }}
{% elif v is sameas None %}
{{ k }} = ""
{% else %}
{{ k }} = {{ v }}
{% endif %}
{% endfor %}
{% endif %}
{% if telegraf_config_outputs %}
{% for name, output in telegraf_config_outputs.items() | default({}) %}
[[outputs.{{ name }}]]
{% for k, v in output.items() | default({}) %}
{% if v is string %}
{{ k }} = "{{ v | quote }}"
{% elif v is sameas True or v is sameas False %}
{{ k }} = {{ v | bool | lower }}
{% elif v is sameas None %}
{{ k }} = ""
{% elif v is number %}
{{ k }} = {{ v }}
{% elif v is sequence %}
{{ k }} = [
{% for i in v | default([]) %}
{{ toml_scalar(i, seq=True) }}
{% endfor %}
]
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
{% if telegraf_config_inputs %}
{% for name, items in telegraf_config_inputs.items() | default({}) %}
{% for item in items %}
[[inputs.{{ name }}]]
{% for k, v in item.items() | default({}) %}
{% if v is string %}
{{ k }} = "{{ v | quote }}"
{% elif v is sameas True or v is sameas False %}
{{ k }} = {{ v | bool | lower }}
{% elif v is sameas None %}
{{ k }} = ""
{% elif v is number %}
{{ k }} = {{ v }}
{% elif v is sequence %}
{{ k }} = [
{% for i in v | default([]) %}
{{ toml_scalar(i, seq=True) }}
{% endfor %}
]
{% endif %}
{% endfor %}
{% else %}
[[inputs.{{ name }}]]
{% endfor %}
{% endfor %}
{% endif %}