Custom exit codes?

Hi all

Probably down to my lack of ruby, but how do/can I exit a recipe, with a custom error code?

I have a resource which may give an error code, and I want to exit depending on the value of it.

  if node.run_state['r_code'] == 600 
    exit(node.run_state['r_code'])
  end

It needs to be executed at the end of the recipe and I can’t put this in a ruby_block, as I just get ChildConvergeError from the resource, and an exit code of 1.

Any help, will be greatly appreciated.

Thanks
Mark

** UPDATE **

if i run the following with chef-zero, I get the error code.

r_code = 600
Chef::Application.fatal!("bailing out!!", 600) if r_code == 600

If I run on a configured client, I always get

FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

I’ve tried adding `exit_status :disabled`` to client.rb, but cannot circumvent the ChildConverge Exception (and therefore exit code 1)

Chef forks a second process to prevent any state created during the run from affecting future runs (also to make Chef's RAM use more predictable over time). Therefore nothing in your recipe code can change Chef's exit code because the parent process isn't running it.

You'll need to find another way to implement whatever it is you want to do.