[chef] Re: How to mark a ruby_block as failed?


Chronological Thread 
  • From: Seth Falcon < >
  • To:
  • Subject: [chef] Re: How to mark a ruby_block as failed?
  • Date: Tue, 21 Dec 2010 12:30:34 -0800

Hi,

On Tue, Dec 21, 2010 at 12:20 PM, Jonathan Weiss 
< >
 wrote:
> I'm using a ruby_block to handle complex operations with mdadm in
> Chef. My question is, how do I tell Chef that my block failed and
> execution should halt with an error? In pseudo code:
>
> ruby_block "A complex operation" do
>  block "using mdadm" do
>    output = `do something`
>    if $?.success?
>      Chef::Log.info output
>    else
>      Chef::Log.error output
>      # tell chef we failed
>    end
>  end
> end
>
> This would of course be easier if I could just use the execute
> resource in the ruby_block...

You can use raise to throw an exception:

if !success
    Chef::Log.fatal("here's some info about why I'm crashing out")
    raise "you can put some msg here too"
end



Archive powered by MHonArc 2.6.16.

§