diff options
author | Luke Kanies <luke@madstop.com> | 2007-11-19 16:03:21 -0600 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2007-11-19 16:03:21 -0600 |
commit | 0ac6b06ac171b2f8a307786ef0446625c3102d38 (patch) | |
tree | 42c94836f382052730bcd72b7ec4dd98ac5492a4 /lib | |
parent | 4bd7b6f69edfc984d153a23872a3ac6e123b5765 (diff) | |
parent | 1b78f57284a37e86db2351c34a2bbf22c43f0275 (diff) | |
download | puppet-0ac6b06ac171b2f8a307786ef0446625c3102d38.tar.gz puppet-0ac6b06ac171b2f8a307786ef0446625c3102d38.tar.xz puppet-0ac6b06ac171b2f8a307786ef0446625c3102d38.zip |
Merge commit 'davids-bugfixes/rest/fix-903'
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/type/exec.rb | 27 |
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) |