Include a Recipe in a Provider


#1

Is it possible to include a recipe in a provider? I have tried using the
include_recipe function both inside the action definition and outside but it
doesn’t seem to be available that way.


#2

Hello,

On Dec 29, 2011, at 12:04 PM, bjbq4d@gmail.com wrote:

Is it possible to include a recipe in a provider? I have tried using the
include_recipe function both inside the action definition and outside but it
doesn’t seem to be available that way.

No, include_recipe isn’t available in cookbook providers/ directories.

You should include the recipe prior to using the provider in another recipe, or ensure it is added to the node’s run list (or in a role).


Opscode, Inc
Joshua Timberman, Technical Program Manager
IRC, Skype, Twitter, Github: jtimberman


#3

On Thu, Dec 29, 2011 at 8:31 PM, Joshua Timberman joshua@opscode.com wrote:

Hello,

On Dec 29, 2011, at 12:04 PM, bjbq4d@gmail.com wrote:

Is it possible to include a recipe in a provider? I have tried using the
include_recipe function both inside the action definition and outside but it
doesn’t seem to be available that way.

No, include_recipe isn’t available in cookbook providers/ directories.

Actually, there is a way:

action :create do
run_context.include_recipe “apache2”


end

That works just fine in my experience.

Andrea


#4

On 30 December 2011 11:11, Andrea Campi andrea.campi@zephirworks.com wrote:

On Thu, Dec 29, 2011 at 8:31 PM, Joshua Timberman joshua@opscode.com wrote:

Hello,

On Dec 29, 2011, at 12:04 PM, bjbq4d@gmail.com wrote:

Is it possible to include a recipe in a provider? I have tried using the
include_recipe function both inside the action definition and outside but it
doesn’t seem to be available that way.

No, include_recipe isn’t available in cookbook providers/ directories.

Actually, there is a way:

action :create do
run_context.include_recipe “apache2”

Does this include the recipe in the outer node context, or the new
context defined in the LWRP? I had some trouble with this WRT
MiniTest, ended up using compile time resources for everything.

If it is being included in the outer node context, this will be fine,
and recipes won’t be duplicated… but if this is a new context for the
LWRP, there is a chance to run a recipe twice - once inside of the
lwrp run_context, and once out… if I recall correctly, or it hasn’t
been fixed… :slight_smile: Careful now!

–AJ


end

That works just fine in my experience.

Andrea


#5

On Thu, Dec 29, 2011 at 11:13 PM, AJ Christensen aj@junglist.gen.nz wrote:

On 30 December 2011 11:11, Andrea Campi andrea.campi@zephirworks.com wrote:

On Thu, Dec 29, 2011 at 8:31 PM, Joshua Timberman joshua@opscode.com wrote:

Hello,

On Dec 29, 2011, at 12:04 PM, bjbq4d@gmail.com wrote:

Is it possible to include a recipe in a provider? I have tried using the
include_recipe function both inside the action definition and outside but it
doesn’t seem to be available that way.

No, include_recipe isn’t available in cookbook providers/ directories.

Actually, there is a way:

action :create do
run_context.include_recipe “apache2”

Does this include the recipe in the outer node context, or the new
context defined in the LWRP? I had some trouble with this WRT
MiniTest, ended up using compile time resources for everything.

Good question, and I’m puzzled: does a new LWRP create a new context?
I would have thought no—if for no other reason, because IIRC a
"sub-run context" cannot notify an “external” run context, and I’m
pretty sure I do.

Anyway, my fork of the application cookbook
(https://github.com/zephirworks/cookbooks/tree/COOK-634) does exactly
this, and we’ve been running it in production for months now with no
ill effect.

Granted, MiniTest is probably doing trickier stuff…

Andrea