mirror of
https://github.com/dj-wasabi/ansible-telegraf.git
synced 2025-07-17 08:46:37 +00:00
Convert the telegraf_plugins_extra varaible to a hash so that we can merge the hashes of multiple var files
This commit is contained in:
@ -70,7 +70,7 @@ The config will be printed line by line into the configuration, so you could als
|
||||
|
||||
and it will be printed in the configuration file.
|
||||
|
||||
There are two properties which are the same, but are used differently. Those are:
|
||||
There are two properties which are similar, but are used differently. Those are:
|
||||
|
||||
* `telegraf_plugins_default`
|
||||
* `telegraf_plugins_extra`
|
||||
@ -90,11 +90,11 @@ With the property `telegraf_plugins_default` it is set to use the default set of
|
||||
|
||||
Every telegraf agent has these as a default configuration.
|
||||
|
||||
The 2nd parameter `telegraf_plugins_extra` can be used to add plugins specific to the servers goal. Following is an example for using this parameter for MySQL database servers:
|
||||
The 2nd parameter `telegraf_plugins_extra` can be used to add plugins specific to the servers goal. It is a hash instead of a list, so that you can merge values from multiple var files together. Following is an example for using this parameter for MySQL database servers:
|
||||
|
||||
cat group_vars/mysql_database
|
||||
telegraf_plugins_extra:
|
||||
- plugin: mysql
|
||||
mysql:
|
||||
config:
|
||||
- servers = ["root:{{ mysql_root_password }}@tcp(localhost:3306)/"]
|
||||
|
||||
|
@ -46,7 +46,7 @@ telegraf_plugins_default:
|
||||
- plugin: kernel
|
||||
|
||||
# extra configuration - /etc/telegraf/telegraf.d/*
|
||||
telegraf_plugins_extra: []
|
||||
telegraf_plugins_extra: {}
|
||||
|
||||
# RedHat specific settings for convenience
|
||||
telegraf_redhat_releasever: "$releasever"
|
||||
|
@ -38,11 +38,11 @@
|
||||
- name: "Copy telegraf extra plugins"
|
||||
template:
|
||||
src: "telegraf-extra-plugin.conf.j2"
|
||||
dest: "/etc/telegraf/telegraf.d/{{ item.filename | default(item.plugin) }}.conf"
|
||||
dest: "/etc/telegraf/telegraf.d/{{ item.value.filename | default(item.key) }}.conf"
|
||||
owner: telegraf
|
||||
group: telegraf
|
||||
mode: 0640
|
||||
with_items: "{{ telegraf_plugins_extra }}"
|
||||
with_dict: "{{ telegraf_plugins_extra }}"
|
||||
when: "telegraf_plugins_extra is defined and telegraf_plugins_extra is iterable"
|
||||
become: yes
|
||||
notify: "Restart Telegraf"
|
||||
|
@ -1,47 +1,47 @@
|
||||
### MANAGED BY {{ role_path|basename }} ANSIBLE ROLE ###
|
||||
|
||||
[[inputs.{{ item.plugin }}]]
|
||||
{% if item.interval is defined %}
|
||||
interval = "{{ item.interval }}s"
|
||||
[[inputs.{{ item.key }}]]
|
||||
{% if item.value.interval is defined %}
|
||||
interval = "{{ item.value.interval }}s"
|
||||
{% endif %}
|
||||
{% if item.config is defined and item.config is iterable %}
|
||||
{% for items in item.config %}
|
||||
{% if item.value.config is defined and item.value.config is iterable %}
|
||||
{% for items in item.value.config %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tags is defined and item.tags is iterable %}
|
||||
[inputs.{{ item.plugin }}.tags]
|
||||
{% for items in item.tags %}
|
||||
{% if item.value.tags is defined and item.value.tags is iterable %}
|
||||
[inputs.{{ item.key }}.tags]
|
||||
{% for items in item.value.tags %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagpass is defined and item.tagpass is iterable %}
|
||||
[{{ item.plugin }}.tagpass]
|
||||
{% for items in item.tagpass %}
|
||||
{% if item.value.tagpass is defined and item.value.tagpass is iterable %}
|
||||
[{{ item.key }}.tagpass]
|
||||
{% for items in item.value.tagpass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.tagdrop is defined and item.tagdrop is iterable %}
|
||||
[{{ item.plugin }}.tagdrop]
|
||||
{% for items in item.tagdrop %}
|
||||
{% if item.value.tagdrop is defined and item.value.tagdrop is iterable %}
|
||||
[{{ item.key }}.tagdrop]
|
||||
{% for items in item.value.tagdrop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.pass is defined and item.pass is iterable %}
|
||||
[{{ item.plugin }}.pass]
|
||||
{% for items in item.pass %}
|
||||
{% if item.value.pass is defined and item.value.pass is iterable %}
|
||||
[{{ item.key }}.pass]
|
||||
{% for items in item.value.pass %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.drop is defined and item.drop is iterable %}
|
||||
[{{ item.plugin }}.drop]
|
||||
{% for items in item.drop %}
|
||||
{% if item.value.drop is defined and item.value.drop is iterable %}
|
||||
[{{ item.key }}.drop]
|
||||
{% for items in item.value.drop %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if item.specifications is defined and item.specifications is iterable %}
|
||||
[[{{item.plugin}}.specifications]]
|
||||
{% for items in item.specifications %}
|
||||
{% if item.value.specifications is defined and item.value.specifications is iterable %}
|
||||
[[{{item.key}}.specifications]]
|
||||
{% for items in item.value.specifications %}
|
||||
{{ items }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
Reference in New Issue
Block a user