From 128faa55b6fa237622cf12f4f091ea86334b6fe7 Mon Sep 17 00:00:00 2001 From: Emerson Knapp Date: Tue, 21 Feb 2017 10:40:19 -0800 Subject: [PATCH] Consolidate instead to a single extra-plugins conf file, to cover the case of multiple instances of same plugin --- tasks/main.yml | 3 +-- templates/telegraf-extra-plugin.conf.j2 | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index eb9efa8..62e51ce 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -34,11 +34,10 @@ - name: "Copy telegraf extra plugins" template: src: "telegraf-extra-plugin.conf.j2" - dest: "/etc/telegraf/telegraf.d/{{ item.plugin }}.conf" + dest: "/etc/telegraf/telegraf.d/extra-plugins.conf" owner: telegraf group: telegraf mode: 0640 - with_items: "{{ telegraf_plugins_extra }}" when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable" become: yes notify: "Restart Telegraf" diff --git a/templates/telegraf-extra-plugin.conf.j2 b/templates/telegraf-extra-plugin.conf.j2 index ff5d188..323f78f 100644 --- a/templates/telegraf-extra-plugin.conf.j2 +++ b/templates/telegraf-extra-plugin.conf.j2 @@ -1,3 +1,5 @@ +{% if telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable %} +{% for item in telegraf_plugins_extra %} [[inputs.{{ item.plugin }}]] {% if item.interval is defined %} interval = "{{ item.interval }}s" @@ -43,3 +45,5 @@ {{ items }} {% endfor %} {% endif %} +{% endfor %} +{% endif %}