mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
moved extra plugins to extra configs in telegraf.d and changed the main.yml to more yml stylish definitions
This commit is contained in:
@ -10,27 +10,39 @@
|
|||||||
when: ansible_os_family == "Debian"
|
when: ansible_os_family == "Debian"
|
||||||
|
|
||||||
- name: "Set fact by remove the dots from version"
|
- name: "Set fact by remove the dots from version"
|
||||||
action: set_fact
|
set_fact:
|
||||||
telegraf_ver="{{ telegraf_agent_version.replace('.','') }}"
|
telegraf_ver: "{{ telegraf_agent_version.replace('.','') }}"
|
||||||
|
|
||||||
- name: "Copy the template for versions < 0.10.0"
|
- name: "Copy the template for versions < 0.10.0"
|
||||||
action: template
|
template:
|
||||||
src=etc-opt-telegraf-telegraf.conf.j2
|
src: etc-opt-telegraf-telegraf.conf.j2
|
||||||
dest=/etc/opt/telegraf/telegraf.conf
|
dest: /etc/opt/telegraf/telegraf.conf
|
||||||
owner=root
|
owner: root
|
||||||
group=root
|
group: root
|
||||||
mode=644
|
mode: 644
|
||||||
when: telegraf_ver < 100
|
when: telegraf_ver < 100
|
||||||
sudo: yes
|
sudo: yes
|
||||||
notify: "Restart Telegraf"
|
notify: "Restart Telegraf"
|
||||||
|
|
||||||
- name: "Copy the template for versions >= 0.10.0"
|
- name: "Copy the template for versions >= 0.10.0"
|
||||||
action: template
|
template:
|
||||||
src=telegraf.conf.j2
|
src: telegraf.conf.j2
|
||||||
dest=/etc/telegraf/telegraf.conf
|
dest: /etc/telegraf/telegraf.conf
|
||||||
owner=root
|
owner: root
|
||||||
group=root
|
group: root
|
||||||
mode=644
|
mode: 644
|
||||||
when: telegraf_ver >= 100
|
when: telegraf_ver >= 100
|
||||||
sudo: yes
|
sudo: yes
|
||||||
notify: "Restart Telegraf"
|
notify: "Restart Telegraf"
|
||||||
|
|
||||||
|
- name: "Copy telegraf extra plugins"
|
||||||
|
template:
|
||||||
|
src: "telegraf.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"
|
@ -68,50 +68,5 @@
|
|||||||
{% endif %}
|
{% 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 %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
0
templates/telegraf-extra-plugin.conf.j2
Normal file
0
templates/telegraf-extra-plugin.conf.j2
Normal file
@ -75,49 +75,4 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% 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 %}
|
{% endif %}
|
Reference in New Issue
Block a user