Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add extra plugins to telegrafd folder #5

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 %}