[chef] Re: How to NOT run a complete recipe?


Chronological Thread 
  • From: Krzysztof Wilczynski < >
  • To:
  • Subject: [chef] Re: How to NOT run a complete recipe?
  • Date: Tue, 29 Sep 2015 23:14:24 +0900

Hello,

Add `return` statement where you need to interrupt the client run, for 
example:

if need_additional_minerals?
 warn 'Not enough minerals!'
 return
end

Krzysztof

On 29 September 2015 at 23:10, Alexander Skwar
< >
 wrote:
> Hello
>
> Using chef-solo and Chef 11.8.2, how do I "exit out" of a recipe?
>
> Sorry to bother you all again, but as I'm not so successful in "filtering
> out" recipes if a pre-condition is (not) met, I'm now looking for a way to
> "leave" a recipe very early, when a condition is met (specifically, if a
> user account cannot be found with "getent passwd foo" (as
> node['etc']['passwd'] doesn't work :()).
>
> Basically, I'd like to have something like:
>
> if env['skip']
>    leave recipe
> end
>
> And "env['skip']" should check the environment variable "skip". If it's set,
> the recipe shouldn't be run.
>
> How can I do that?
>
> Thanks a lot and best regards,
> Alexander



Archive powered by MHonArc 2.6.16.

§