From 3408a8f0f53f3bad2ebfc2951573c6cf58301010 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 9 Mar 2016 10:23:45 -0600 Subject: [PATCH] Don't post reports if there are no reports to post If we don't produce any reports, don't post them. Change-Id: I06f0bf47a1761f90118ad45a99e33f112699a4c7 --- tasks/main.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tasks/main.yml b/tasks/main.yml index c4bdd8a..bb96948 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -70,16 +70,19 @@ - name: set log filename set_fact: puppet_logfile="{{ files.stdout_lines|sort|last }}" + when: "{{ files.stdout_lines|length > 0 }}" - name: create reports directory file: path=/var/lib/puppet/reports/{{ ansible_fqdn }} owner=root group=root mode=0755 state=directory delegate_to: localhost + when: "{{ files.stdout_lines|length > 0 }}" - name: fetch file synchronize: mode: pull src: "{{ puppet_logfile }}" dest: /var/lib/puppet/reports/{{ ansible_fqdn }} + when: "{{ files.stdout_lines|length > 0 }}" - name: post facts puppet_post_puppetdb: @@ -89,5 +92,6 @@ whoami: "{{ puppet_report_as }}" delegate_to: localhost connection: local + when: "{{ files.stdout_lines|length > 0 }}" when: puppetdb is defined and puppet_report_as is defined