feat: add submodule for inputs

This commit is contained in:
Adrien Waksberg 2021-10-13 16:25:21 +02:00
parent bb8fab5b9d
commit e870e0971c
4 changed files with 27 additions and 0 deletions

View file

@ -5,6 +5,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
## [Unreleased]
### Added
- add submode for inputs
## v1.0.0 - 2021-08-20
### Added

View file

@ -38,6 +38,14 @@ Install and configure Telegraf
totalcpu: true
collect_cpu_time: false
report_active: false
postgresql_extensible:
address: "host=localhost"
submodule:
- name: query
version = 901
sqlquery = "SELECT pg_is_in_recovery()::INT"
withdbname = false
tagvalue = ""
```
* `telegraf_outputs` - hash with outputs configuration

View file

@ -1,6 +1,7 @@
---
galaxy_info:
role_name: telegraf
namespace: nishiki
author: Adrien Waksberg
company: Adrien Waksberg
description: Install and configure Telegraf

View file

@ -27,11 +27,25 @@
[[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 %}