Hi all,
Is there some official (or at least working) way to stop execution of a
recipe early? (without affecting the rest of the run list)
For example if I have the whole recipe depending on a single switch, I could
just put it inside of:
if node[:switch]
…
end
but that would be spanning a couple of screens of code - not the cleanest
solution. Is there a good way to stop execution without throwing an
exception, so that I can do:
some_stop_function unless node[:switch]
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard
Hi,
We occasionally need to do this to coordinate converges across multiple
nodes. The way we have typically done this is by defining a cookbook that
has a recipe that simply includes all the other recipes and then we put
guards on them like
include_recipe "linux-base"
include_recipe "server-setup" unless node['switch']
unless node['switch2']
include_recipe "app-deploy"
include_recipe "monitor-up"
end
Not sure if that helps...
On Wednesday, October 17, 2012, Pitucha, Stanislaw Izaak wrote:
Hi all,
Is there some official (or at least working) way to stop execution of a
recipe early? (without affecting the rest of the run list)
For example if I have the whole recipe depending on a single switch, I
could
just put it inside of:
if node[:switch]
....
end
but that would be spanning a couple of screens of code - not the cleanest
solution. Is there a good way to stop execution without throwing an
exception, so that I can do:
some_stop_function unless node[:switch]
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard
--
Cheers,
Peter Donald
you can 'return' from the recipe DSL mid-compilation.
cheers,
--AJ
On 17 October 2012 23:11, Pitucha, Stanislaw Izaak
stanislaw.pitucha@hp.com wrote:
Hi all,
Is there some official (or at least working) way to stop execution of a
recipe early? (without affecting the rest of the run list)
For example if I have the whole recipe depending on a single switch, I could
just put it inside of:
if node[:switch]
....
end
but that would be spanning a couple of screens of code - not the cleanest
solution. Is there a good way to stop execution without throwing an
exception, so that I can do:
some_stop_function unless node[:switch]
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard
To expand; apologies: occasionally we'd skip the entire execution of a
recipe depending solely upon the results from our Discovery [0]
library cookbook.
A common (gated) execution pattern is:
return unless discovery_search("a_servers_role_that_ineed",
:empty_ok => false,
:environment_aware => true)
Cheers,
--AJ
[0] GitHub - hw-cookbooks/discovery: Discovery cookbook for search, implements Discovery#search environment and non-environment aware search for roles with a few extra checks
On 17 October 2012 23:38, AJ Christensen aj@junglist.gen.nz wrote:
you can 'return' from the recipe DSL mid-compilation.
cheers,
--AJ
On 17 October 2012 23:11, Pitucha, Stanislaw Izaak
stanislaw.pitucha@hp.com wrote:
Hi all,
Is there some official (or at least working) way to stop execution of a
recipe early? (without affecting the rest of the run list)
For example if I have the whole recipe depending on a single switch, I could
just put it inside of:
if node[:switch]
....
end
but that would be spanning a couple of screens of code - not the cleanest
solution. Is there a good way to stop execution without throwing an
exception, so that I can do:
some_stop_function unless node[:switch]
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard
Thanks, I tried 'return' in shef, which failed, so I assumed it would fail in chef-client too. Apparently that's not the case.
chef:recipe > return
ThreadError: return can't jump across threads
from (irb#1):1
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard
-----Original Message-----
From: AJ Christensen [mailto:aj@junglist.gen.nz]
Sent: Wednesday, October 17, 2012 11:41 AM
To: chef@lists.opscode.com
Subject: [chef] Re: stopping recipe execution early
To expand; apologies: occasionally we'd skip the entire execution of a recipe depending solely upon the results from our Discovery [0] library cookbook.
A common (gated) execution pattern is:
return unless discovery_search("a_servers_role_that_ineed",
:empty_ok => false,
:environment_aware => true)
Cheers,
--AJ
[0] GitHub - hw-cookbooks/discovery: Discovery cookbook for search, implements Discovery#search environment and non-environment aware search for roles with a few extra checks
On 17 October 2012 23:38, AJ Christensen aj@junglist.gen.nz wrote:
you can 'return' from the recipe DSL mid-compilation.
cheers,
--AJ
On 17 October 2012 23:11, Pitucha, Stanislaw Izaak
stanislaw.pitucha@hp.com wrote:
Hi all,
Is there some official (or at least working) way to stop execution of
a recipe early? (without affecting the rest of the run list) For
example if I have the whole recipe depending on a single switch, I
could just put it inside of:
if node[:switch]
....
end
but that would be spanning a couple of screens of code - not the
cleanest solution. Is there a good way to stop execution without
throwing an exception, so that I can do:
some_stop_function unless node[:switch]
Regards,
Stanisław Pitucha
Cloud Services
Hewlett Packard