- From: Daniel DeLeo <
- Subject: [chef] Re: stdout/stderr and exception/report framework
- Date: Mon, 9 Apr 2012 10:46:38 -0700
On Monday, April 9, 2012 at 10:11 AM, 2bjc 466 wrote:
> Hi list,
> We have two issues with chef at the moment. The first is that we want to
> write execute resources that leverage rsync and be able to behave in
> different ways based on the stderr/stdout of the rsync command. It looks
> like chef is specifically written to discard stderr/stdout with the
> exception of console output, which isn't useful outside of debugging
> if STDOUT.tty? && !Chef::Config[:daemon] && Chef::Log.info
> opts[:live_stream] = STDOUT
> The second is that we would like to use chef's exception/report framework
> that is available after throwing an exception, but without throwing an
> exception. Is there a way to trigger an exception that does not cause chef
> to fail, or a way to use the exception/report framework without throwing an
> exception? There are many cases where we want to be notified of changes on
> a chef client, but do not want chef to terminate.
Exception handlers run on failure, whereas report handlers run on success.
They actually use the same API, so you could write/configure a handler plugin
to do both if you like.
> Currently we are working on redefining the Chef::RunStatus class to give us
> stderr/stdout, and writing a custom execute resource to pipe the
> stderr/stdout. If there are ways to do this without modifying chef
> internals, let us know, as we would prefer to run a vanilla chef install.
You could write a LWRP that uses the ShellOut code to run rsync and then
makes decisions based on the output. ShellOut recently got extracted to its
own project (mixlib-shellout), you can read the inline documentation here:
Within Chef, you can `include Chef::MixinShellOut` to get helper functions
that allow you to execute commands without going through the OOP dance:
Archive powered by MHonArc 2.6.16.