Merge pull request #60 from gaizeror/wipe-non-ansible-extra-plugins

Added support for plugins being managed exclusively by this playbook
This commit is contained in:
Werner Dijkerman
2018-08-20 18:46:56 +02:00
committed by GitHub
3 changed files with 26 additions and 0 deletions

View File

@ -98,6 +98,7 @@ The 2nd parameter `telegraf_plugins_extra` can be used to add plugins specific t
config:
- servers = ["root:{{ mysql_root_password }}@tcp(localhost:3306)/"]
There is an option to delete extra-plugin files in /etc/telegraf/telegraf.d if they weren't generated by this playbook with `telegraf_plugins_extra_exclusive` variable.
Telegraf plugin options:

View File

@ -47,6 +47,7 @@ telegraf_plugins_default:
# extra configuration - /etc/telegraf/telegraf.d/*
telegraf_plugins_extra: {}
telegraf_plugins_extra_exclusive: False
# RedHat specific settings for convenience
telegraf_redhat_releasever: "$releasever"

View File

@ -35,6 +35,30 @@
when: telegraf_agent_version is version_compare('0.10.0', '>=')
notify: "Restart Telegraf"
- name: "Check if extra plugins directory exists in case of exclusive"
action: stat path=/etc/telegraf/telegraf.d
register: telegraf_directory
when: telegraf_plugins_extra_exclusive
- name: "Delete telegraf extra plugin path"
file:
state: absent
path: "/etc/telegraf/telegraf.d/"
when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists
become: yes
notify: "Restart Telegraf"
- name: "Create telegraf extra plugin path"
file:
state: directory
path: "/etc/telegraf/telegraf.d/"
owner: telegraf
group: telegraf
mode: 0740
when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists
become: yes
notify: "Restart Telegraf"
- name: "Copy telegraf extra plugins"
template:
src: "telegraf-extra-plugin.conf.j2"