Return from Chef recipe without rising an exception

chefconfiguration-managementdeployment

Is there a way to return from Chef recipe without rising an exception?

Say I have a long recipe. I want to add a ruby block to it's beginning which will check some condition (for example directory presence) and stop processing this recipe (but continue to execute the rest of run_list) without raising an exception if condition succeeds.

Conditional execution (only_if/not_if) doesn't solve the problem because I have to add the condition to every resource call in the recipe while there may be very many of them.

There is a comment in Opscode's wiki where the commenter asks about the same but no answer.

Best Answer

The way to abort run of a recipe (e.g. due to some condition) is to use a 'return' statement. A thorough discussion appears in jtimberman's answer to a parallel StackOverflow question.