summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/exec.rb27
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb
index 9aab4dbd7..5bb3158c4 100755
--- a/lib/puppet/type/exec.rb
+++ b/lib/puppet/type/exec.rb
@@ -113,15 +113,16 @@ module Puppet
self.fail "Command exceeded timeout" % value.inspect
end
- loglevel = @resource[:loglevel]
- if status.exitstatus.to_s != self.should.to_s
- self.fail("%s returned %s instead of %s" %
- [self.resource[:command], status.exitstatus, self.should.to_s])
- end
-
if log = @resource[:logoutput]
- if log == :true
+ case log
+ when :true
log = @resource[:loglevel]
+ when :on_failure
+ if status.exitstatus.to_s != self.should.to_s
+ log = @resource[:loglevel]
+ else
+ log = :false
+ end
end
unless log == :false
@output.split(/\n/).each { |line|
@@ -130,6 +131,11 @@ module Puppet
end
end
+ if status.exitstatus.to_s != self.should.to_s
+ self.fail("%s returned %s instead of %s" %
+ [self.resource[:command], status.exitstatus, self.should.to_s])
+ end
+
return event
end
end
@@ -201,10 +207,11 @@ module Puppet
newparam(:logoutput) do
desc "Whether to log output. Defaults to logging output at the
- loglevel for the ``exec`` resource. Values are **true**, *false*,
- and any legal log level."
+ loglevel for the ``exec`` resource. Use *on_failure* to only
+ log the output when the command reports an error. Values are
+ **true**, *false*, *on_failure*, and any legal log level."
- values = [:true, :false]
+ values = [:true, :false, :on_failure]
# And all of the log levels
Puppet::Util::Log.eachlevel { |level| values << level }
newvalues(*values)