Get calling recipe


#1

Is there a way to get the name of a calling recipe?

Say cookbook1::recipe-a has:
include_recipe “cookbook2::recipe-b”

Then in cookbook2::recipe-b we have:
puts get_calling_recipe.name

Regards,
Dave


#2

There is no “calling recipe” per se, all recipes are executed independently so there isn’t a useful call stack if thats what you mean. You can access the current cookbook/recipe via cookbook_name and recipe_name.

–Noah

On Jun 9, 2014, at 1:38 PM, Dave Urschatz durschatz@blackberry.com wrote:

Is there a way to get the name of a calling recipe?

Say cookbook1::recipe-a has:
include_recipe “cookbook2::recipe-b”

Then in cookbook2::recipe-b we have:
puts get_calling_recipe.name

Regards,
Dave


#3

Have you tried node.run_state?

Its a Hash available on the node object that you can use.

Notifications and Subscriptions can change the order in which
resources get executed. So please do keep that in mind.

See - “Chef’s dirty secret: Convergence is also Compilation”

http://erik.hollensbe.org/2013/03/16/the-chef-resource-run-queue/

Best,
Rajiv

On Mon, Jun 9, 2014 at 4:58 PM, Noah Kantrowitz noah@coderanger.net wrote:

There is no “calling recipe” per se, all recipes are executed independently so there isn’t a useful call stack if thats what you mean. You can access the current cookbook/recipe via cookbook_name and recipe_name.

–Noah

On Jun 9, 2014, at 1:38 PM, Dave Urschatz durschatz@blackberry.com wrote:

Is there a way to get the name of a calling recipe?

Say cookbook1::recipe-a has:
include_recipe “cookbook2::recipe-b”

Then in cookbook2::recipe-b we have:
puts get_calling_recipe.name

Regards,
Dave


#4

Thanks Noah.

-----Original Message-----
From: Noah Kantrowitz [mailto:noah@coderanger.net]
Sent: Monday, June 09, 2014 7:58 PM
To: Dave Urschatz
Cc: chef-dev@lists.opscode.com
Subject: Re: [chef-dev] get calling recipe

There is no “calling recipe” per se, all recipes are executed independently so there isn’t a useful call stack if thats what you mean. You can access the current cookbook/recipe via cookbook_name and recipe_name.

–Noah

On Jun 9, 2014, at 1:38 PM, Dave Urschatz durschatz@blackberry.com wrote:

Is there a way to get the name of a calling recipe?

Say cookbook1::recipe-a has:
include_recipe “cookbook2::recipe-b”

Then in cookbook2::recipe-b we have:
puts get_calling_recipe.name

Regards,
Dave


#5

Thanks Rajiv.

I will look into this.

Regards,
Dave

-----Original Message-----
From: Rajiv Ranganath [mailto:rajiv.ranganath@atihita.com]
Sent: Monday, June 09, 2014 8:40 PM
To: Noah Kantrowitz
Cc: Dave Urschatz; chef-dev@lists.opscode.com
Subject: Re: [chef-dev] Re: get calling recipe

Have you tried node.run_state?

Its a Hash available on the node object that you can use.

Notifications and Subscriptions can change the order in which resources get executed. So please do keep that in mind.

See - “Chef’s dirty secret: Convergence is also Compilation”

http://erik.hollensbe.org/2013/03/16/the-chef-resource-run-queue/

Best,
Rajiv

On Mon, Jun 9, 2014 at 4:58 PM, Noah Kantrowitz noah@coderanger.net wrote:

There is no “calling recipe” per se, all recipes are executed independently so there isn’t a useful call stack if thats what you mean. You can access the current cookbook/recipe via cookbook_name and recipe_name.

–Noah

On Jun 9, 2014, at 1:38 PM, Dave Urschatz durschatz@blackberry.com wrote:

Is there a way to get the name of a calling recipe?

Say cookbook1::recipe-a has:
include_recipe “cookbook2::recipe-b”

Then in cookbook2::recipe-b we have:
puts get_calling_recipe.name

Regards,
Dave