From c2ed04aa2aea81cfca943aa750ed614926390ba4 Mon Sep 17 00:00:00 2001 From: Michele Baldessari Date: Sun, 18 Feb 2018 22:20:47 +0100 Subject: [PATCH] WIP do return changed exit code if noop and out of sync resources https://tickets.puppetlabs.com/browse/PUP-686 --- lib/puppet/application/apply.rb | 4 ++++ lib/puppet/transaction/report.rb | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/puppet/application/apply.rb b/lib/puppet/application/apply.rb index 6b96c82db35a..1e452b96d3ae 100644 --- a/lib/puppet/application/apply.rb +++ b/lib/puppet/application/apply.rb @@ -101,6 +101,10 @@ configuration options can also be generated by running puppet with 6: The run succeeded, and included both changes and failures. + When running with --noop (and no resources have been explicitely set to noop => false) + it will return 0 for no changes (the system would already be in the desired state) + and it will return 2 for changes would be needed. + * --help: Print this help message diff --git a/lib/puppet/transaction/report.rb b/lib/puppet/transaction/report.rb index 1f4234de8488..d78216d77994 100644 --- a/lib/puppet/transaction/report.rb +++ b/lib/puppet/transaction/report.rb @@ -393,6 +393,9 @@ class Puppet::Transaction::Report # def exit_status status = 0 + if @noop && @metrics["resources"] && @metrics["resources"]["out_of_sync"] + status |= 2 if @metrics["resources"]["out_of_sync"] > 0 + end if @metrics["changes"] && @metrics["changes"]["total"] && @metrics["resources"] && @metrics["resources"]["failed"] && @metrics["resources"]["failed_to_restart"] -- 2.14.3