Skip to content

Commit

Permalink
Merge pull request #5 from stvnwrgs/feature/add_extra_plugins_to_tele…
Browse files Browse the repository at this point in the history
…grafd_folder

Feature/add extra plugins to telegrafd folder
  • Loading branch information
Werner Dijkerman authored Jun 23, 2016
2 parents 4bd9a85 + 01d05b0 commit 6e990c9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 104 deletions.
40 changes: 26 additions & 14 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,39 @@
when: ansible_os_family == "Debian"

- name: "Set fact by remove the dots from version"
action: set_fact
telegraf_ver="{{ telegraf_agent_version.replace('.','') }}"
set_fact:
telegraf_ver: "{{ telegraf_agent_version.replace('.','') }}"

- name: "Copy the template for versions < 0.10.0"
action: template
src=etc-opt-telegraf-telegraf.conf.j2
dest=/etc/opt/telegraf/telegraf.conf
owner=root
group=root
mode=644
template:
src: etc-opt-telegraf-telegraf.conf.j2
dest: /etc/opt/telegraf/telegraf.conf
owner: root
group: root
mode: 644
when: telegraf_ver < 100
sudo: yes
notify: "Restart Telegraf"

- name: "Copy the template for versions >= 0.10.0"
action: template
src=telegraf.conf.j2
dest=/etc/telegraf/telegraf.conf
owner=root
group=root
mode=644
template:
src: telegraf.conf.j2
dest: /etc/telegraf/telegraf.conf
owner: root
group: root
mode: 644
when: telegraf_ver >= 100
sudo: yes
notify: "Restart Telegraf"

- name: "Copy telegraf extra plugins"
template:
src: "telegraf-extra-plugin.conf.j2"
dest: "/etc/telegraf/telegraf.d/{{ item.plugin }}.conf"
owner: root
group: root
mode: 644
with_items: "{{ telegraf_plugins_extra }}"
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable"
sudo: yes
notify: "Restart Telegraf"
45 changes: 0 additions & 45 deletions templates/etc-opt-telegraf-telegraf.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -68,50 +68,5 @@
{% endif %}


{% endfor %}
{% endif %}

{% if telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable %}
{% for item in telegraf_plugins_extra %}
[{{ item.plugin }}]
{% if item.interval is defined %}
interval = "{{ item.interval }}s"
{% endif %}
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[{{ item.plugin }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[{{ item.plugin }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.pass is defined and item.pass is iterable %}
[{{ item.plugin }}.pass]
{% for items in item.pass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.drop is defined and item.drop is iterable %}
[{{ item.plugin }}.drop]
{% for items in item.drop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.specifications is defined and item.specifications is iterable %}
[[{{item.plugin}}.specifications]]
{% for items in item.specifications %}
{{ items }}
{% endfor %}
{% endif %}

{% endfor %}
{% endif %}
44 changes: 44 additions & 0 deletions templates/telegraf-extra-plugin.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

{% 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"
{% endif %}
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[{{ item.plugin }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[{{ item.plugin }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.pass is defined and item.pass is iterable %}
[{{ item.plugin }}.pass]
{% for items in item.pass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.drop is defined and item.drop is iterable %}
[{{ item.plugin }}.drop]
{% for items in item.drop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.specifications is defined and item.specifications is iterable %}
[[{{item.plugin}}.specifications]]
{% for items in item.specifications %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}
45 changes: 0 additions & 45 deletions templates/telegraf.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -75,49 +75,4 @@
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}


{% 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"
{% endif %}
{% if item.config is defined and item.config is iterable %}
{% for items in item.config %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagpass is defined and item.tagpass is iterable %}
[{{ item.plugin }}.tagpass]
{% for items in item.tagpass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.tagdrop is defined and item.tagdrop is iterable %}
[{{ item.plugin }}.tagdrop]
{% for items in item.tagdrop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.pass is defined and item.pass is iterable %}
[{{ item.plugin }}.pass]
{% for items in item.pass %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.drop is defined and item.drop is iterable %}
[{{ item.plugin }}.drop]
{% for items in item.drop %}
{{ items }}
{% endfor %}
{% endif %}
{% if item.specifications is defined and item.specifications is iterable %}
[[{{item.plugin}}.specifications]]
{% for items in item.specifications %}
{{ items }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

0 comments on commit 6e990c9

Please sign in to comment.