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
This commit is contained in:
Yolanda Robla 2016-02-26 01:58:49 +01:00
parent 54fabcffd1
commit 139ca911ab
1 changed files with 1 additions and 0 deletions

View File

@ -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 }}"