From 139ca911ab4bda969f24b7a5d0a28e3f49893e70 Mon Sep 17 00:00:00 2001 From: Yolanda Robla Date: Fri, 26 Feb 2016 01:58:49 +0100 Subject: [PATCH] Safely fail when logs cannot be found On first runs, this logfile is not going to be found. This is causing ansible to crash and stop applying puppet in consecutive nodes. Add a condition to safely fail, and abort play if no files can be found. Change-Id: I22a5ebbcaa603b25920fd638211f3663e81e09b0 --- tasks/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/main.yml b/tasks/main.yml index fbfdd3e..001afe1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -67,6 +67,7 @@ - name: find logs shell: "ls -tr /var/lib/puppet/reports/{{ ansible_fqdn }}/*_puppetdb.json" register: files + failed_when: files.stdout_lines|default("") == "" - name: set log filename set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}"