- From: Daniel DeLeo <
>
- To:
- Subject: [chef] Re: Re: Re: Re: How to NOT run a complete recipe?
- Date: Tue, 29 Sep 2015 09:21:31 -0700
To skip to the end of the entire run without causing an error, you can `throw
:end_client_run_early` which will jump up to here:
https://github.com/chef/chef/blob/8f65f75b2ae48ed33cfce1853edcdcc1a949b9c3/lib/chef/client.rb#L648
This can definitely skip all kinds of reporting stuff, right now it’s
primarily used to trigger a system restart when that is required for chef to
continue to make progress converging the machine (as is common on windows).
--
Daniel DeLeo
On Tuesday, September 29, 2015 at 8:46 AM, Ranjib Dey wrote:
>
not sure if return will work, you might get a local jump error, since the
>
recipes are instance_evaled.
>
you should do this on top level recipe or wrapper recipes, i.e check for
>
the condition, and include_recipe accordingly., i.e.
>
>
>
# in parent recipe cookbook::parent
>
if node.foo.bar
>
include_recipe 'cookbook::child'
>
end
>
>
On Tue, Sep 29, 2015 at 8:03 AM, Alexander Skwar
>
<
>
>
(mailto:
)>
>
wrote:
>
> Hi
>
>
>
> Thanks a lot. And to completely exit out of the chef run, "raise" would
>
> be the way to go. Possibly with a Chef::Log message before.
>
>
>
> Thanks a lot,
>
> Alexander
>
>
>
> 2015-09-29 16:16 GMT+02:00 Krzysztof Wilczynski
>
> <
>
>
>
> (mailto:
)>:
>
> > Hi,
>
> >
>
> > Doh.
>
> >
>
> > I will correct myself - not interrupt the client run, but rather
>
> > return from the recipe without progressing further.
>
> >
>
> > Krzysztof
>
> >
>
> > On 29 September 2015 at 23:14, Krzysztof Wilczynski
>
> > <
>
> >
>
> > (mailto:
)>
>
> > wrote:
>
> > > 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
>
> > > <
>
> > >
>
> > > (mailto:
)>
>
> > > 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
>
> > >
>
> >
>
>
>
>
>
>
>
>
>
> --
>
>
>
> Alexander -- => Google+ => http://plus.skwar.me (http://plus.skwar.me/)
>
> <== => Chat (Jabber/Google Talk) =>
>
>
>
>
>
> (mailto:
)
>
> <==
Archive powered by MHonArc 2.6.16.