[FIX] added a check if dir exists, else skip

This commit is contained in:
or
2018-08-18 12:32:42 +03:00
parent fa75297915
commit a49e82bf12

View File

@ -35,11 +35,15 @@
when: telegraf_agent_version is version_compare('0.10.0', '>=') when: telegraf_agent_version is version_compare('0.10.0', '>=')
notify: "Restart Telegraf" notify: "Restart Telegraf"
- action: stat path=/etc/telegraf/telegraf.d
register: telegraf_directory
when: telegraf_plugins_extra_exclusive
- name: "Delete telegraf extra plugin path" - name: "Delete telegraf extra plugin path"
file: file:
state: absent state: absent
path: "/etc/telegraf/telegraf.d/" path: "/etc/telegraf/telegraf.d/"
when: "telegraf_plugins_extra_exclusive == True" when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists
become: yes become: yes
notify: "Restart Telegraf" notify: "Restart Telegraf"
@ -50,7 +54,7 @@
owner: telegraf owner: telegraf
group: telegraf group: telegraf
mode: 0740 mode: 0740
when: "telegraf_plugins_extra_exclusive == True" when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists
become: yes become: yes
notify: "Restart Telegraf" notify: "Restart Telegraf"