From a49e82bf12f99d3d17794aa847a61f4f184619f7 Mon Sep 17 00:00:00 2001 From: or Date: Sat, 18 Aug 2018 12:32:42 +0300 Subject: [PATCH] [FIX] added a check if dir exists, else skip --- tasks/configure.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tasks/configure.yml b/tasks/configure.yml index 8ee1d83..eeb8dbb 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -35,11 +35,15 @@ when: telegraf_agent_version is version_compare('0.10.0', '>=') notify: "Restart Telegraf" +- 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 == True" + when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists become: yes notify: "Restart Telegraf" @@ -50,7 +54,7 @@ owner: telegraf group: telegraf mode: 0740 - when: "telegraf_plugins_extra_exclusive == True" + when: telegraf_plugins_extra_exclusive and telegraf_directory.stat.exists become: yes notify: "Restart Telegraf"