diff options
author | David Schmitt <david@schmitt.edv-bus.at> | 2007-11-19 10:21:56 +0100 |
---|---|---|
committer | David Schmitt <david@schmitt.edv-bus.at> | 2007-11-19 10:21:56 +0100 |
commit | 1b78f57284a37e86db2351c34a2bbf22c43f0275 (patch) | |
tree | 7d3c543c7c9879ffee7ef5c0d554d0ea880a2223 /lib | |
parent | 4afbaa6f7042eb1cccc8938ee1ccb53c662ba41c (diff) | |
download | puppet-1b78f57284a37e86db2351c34a2bbf22c43f0275.tar.gz puppet-1b78f57284a37e86db2351c34a2bbf22c43f0275.tar.xz puppet-1b78f57284a37e86db2351c34a2bbf22c43f0275.zip |
Add Exec{ logoutput=> on_failure }
This option only writes the output of the command to the log if the command
failed.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/type/exec.rb | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/puppet/type/exec.rb b/lib/puppet/type/exec.rb index b76426495..5bb3158c4 100755 --- a/lib/puppet/type/exec.rb +++ b/lib/puppet/type/exec.rb @@ -114,8 +114,15 @@ module Puppet 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| @@ -200,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) |