# I am not loading \<cookbook::recipe\> because I have already seen it

**URL:** <https://discourse.chef.io/t/i-am-not-loading-cookbook-recipe-because-i-have-already-seen-it/5700>\
**Category:** Chef Infra (archive)\
**Created:** [August 6, 2014, 8:23pm UTC](https://discourse.chef.io/t/i-am-not-loading-cookbook-recipe-because-i-have-already-seen-it/5700 "2014-08-06T20:23:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnewb](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jnewb](https://discourse.chef.io/u/jnewb)\
**Post date:** [August 6, 2014, 8:23pm UTC](https://discourse.chef.io/t/i-am-not-loading-cookbook-recipe-because-i-have-already-seen-it/5700/1 "2014-08-06T20:23:10Z")

</div>

Hi folks,

I am a relatively new Chef user running chef solo on linux. I’m running into a  
problem when trying to invoke a community cookbook/recipe multiple times with  
different databags. I’m hoping to find some advice/help.

Some details:

I have a “common” role definition and its runlist contains a wrapper recipe (a)  
which loads some data from a databag (b) and uses “include\_recipe” to  
load/invoke a 3rd party cookbook/recipe ©. This all works as expected. I  
also have a role specific role definition with a runlist that contains a  
different wrapper recipe (d) which, similarly, loads some data from a DIFFERENT  
databag (e) and uses “include\_recipe” to load/invoke the SAME 3rd party  
cookbook/recipe ©. What I’m finding is that the third party recipe doesn’t  
get invoked by “include\_recipe” the second time.

When I run in debug mode, I see that my combined runlist is accurate, but later  
down the log, I see the message, “I am not loading cookbook::recipe because I  
have already seen it.”

I realize that chef converges such that recipes don’t get loaded twice, but I’m  
not sure how to reconcile that convergence with the results that I’m after. Is  
there a way to invoke the loaded recipe a second time (with different data)?  
Is my model/understanding flawed? Am I doing it wrong?

I did come across this old bug which describes a similar problem, but the  
workaround doesn’t seem to work anymore and the proper solution isn’t very  
clear (to a newbie).

[https://tickets.opscode.com/browse/CHEF-1406](https://tickets.opscode.com/browse/CHEF-1406)

Thanks in advance for any constructive advice.

---

<div class="post-metadata">

**Author:** ![Joshua\_Timberman1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joshua_timberman1/32/188_2.png) [@Joshua\_Timberman1](https://discourse.chef.io/u/Joshua_Timberman1)\
**Post date:** [August 18, 2014, 4:49am UTC](https://discourse.chef.io/t/i-am-not-loading-cookbook-recipe-because-i-have-already-seen-it/5700/2 "2014-08-18T04:49:14Z")

</div>

This is exactly the kind of thing I'd use a definition to do. In a post I  
wrote earlier this year about cookbook development, I discuss the use of a  
definition in our 'chef-splunk' cookbook.

> **[Evolution of Cookbook Development - Chef Blog | Chef](https://www.chef.io/blog/evolution-of-cookbook-development)**
>
> In this post, I will explore some development patterns that I’ve seen (and done!) with Chef cookbooks, and then explain how we can evolve to a new level of cookbook development.

Documentation about definitions here:

[http://docs.getchef.com/essentials\_cookbook\_definitions.html](http://docs.getchef.com/essentials_cookbook_definitions.html)

Hope this helps,  
Joshua

On Wed, Aug 6, 2014 at 2:23 PM, Jason Newblanc \<  
[jason.newblanc@servicenow.com](mailto:jason.newblanc@servicenow.com)\> wrote:

> Hi folks,
> 
> I am a relatively new Chef user running chef solo on linux. I'm running  
> into a  
> problem when trying to invoke a community cookbook/recipe multiple times  
> with  
> different databags. I'm hoping to find some advice/help.
> 
> Some details:
> 
> I have a "common" role definition and its runlist contains a wrapper  
> recipe (a)  
> which loads some data from a databag (b) and uses "include\_recipe" to  
> load/invoke a 3rd party cookbook/recipe (c). This all works as expected.  
> I  
> also have a role specific role definition with a runlist that contains a  
> different wrapper recipe (d) which, similarly, loads some data from a  
> DIFFERENT  
> databag (e) and uses "include\_recipe" to load/invoke the SAME 3rd party  
> cookbook/recipe (c). What I'm finding is that the third party recipe  
> doesn't  
> get invoked by "include\_recipe" the second time.
> 
> When I run in debug mode, I see that my combined runlist is accurate, but  
> later  
> down the log, I see the message, "I am not loading cookbook::recipe  
> because I  
> have already seen it."
> 
> I realize that chef converges such that recipes don't get loaded twice,  
> but I'm  
> not sure how to reconcile that convergence with the results that I'm  
> after. Is  
> there a way to invoke the loaded recipe a second time (with different  
> data)?  
> Is my model/understanding flawed? Am I doing it wrong?
> 
> I did come across this old bug which describes a similar problem, but the  
> workaround doesn't seem to work anymore and the proper solution isn't very  
> clear (to a newbie).
> 
> [https://tickets.opscode.com/browse/CHEF-1406](https://tickets.opscode.com/browse/CHEF-1406)
> 
> Thanks in advance for any constructive advice.

---

<div class="post-metadata">

**Author:** ![Ranjib](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ranjib/32/1040_2.png) [@Ranjib](https://discourse.chef.io/u/Ranjib)\
**Post date:** [August 6, 2014, 10:24pm UTC](https://discourse.chef.io/t/i-am-not-loading-cookbook-recipe-because-i-have-already-seen-it/5700/3 "2014-08-06T22:24:17Z")

</div>

those warnings are from a stages that are before chef execution. All  
recipes in chef gets compiled into a flat resource list. Then the resource  
list is executed one by one. First phase is called compilation. As each of  
the recipes gets compiled (recipe name -\> resource list) its added in  
loaded\_recipes place holder (which internally used to check whether a  
recipe needs to be included or not).

chef is raw ruby, so you can remove that recipe using the internal api.  
this will be brittle (what if chef api changes?) also because the  
resources inside the recipes are already added will be duplicated (rather  
cloned) and the net outcome can be even more unpredictable (behavior of  
notifications, resource cloning will depend up provider/resource  
implementations ),

what exactly you are trying to do ? may be theres a cleaner way to do it,

cheers  
ranjib

On Wed, Aug 6, 2014 at 1:23 PM, Jason Newblanc \<  
[jason.newblanc@servicenow.com](mailto:jason.newblanc@servicenow.com)\> wrote:

> Hi folks,
> 
> I am a relatively new Chef user running chef solo on linux. I'm running  
> into a  
> problem when trying to invoke a community cookbook/recipe multiple times  
> with  
> different databags. I'm hoping to find some advice/help.
> 
> Some details:
> 
> I have a "common" role definition and its runlist contains a wrapper  
> recipe (a)  
> which loads some data from a databag (b) and uses "include\_recipe" to  
> load/invoke a 3rd party cookbook/recipe (c). This all works as expected.  
> I  
> also have a role specific role definition with a runlist that contains a  
> different wrapper recipe (d) which, similarly, loads some data from a  
> DIFFERENT  
> databag (e) and uses "include\_recipe" to load/invoke the SAME 3rd party  
> cookbook/recipe (c). What I'm finding is that the third party recipe  
> doesn't  
> get invoked by "include\_recipe" the second time.
> 
> When I run in debug mode, I see that my combined runlist is accurate, but  
> later  
> down the log, I see the message, "I am not loading cookbook::recipe  
> because I  
> have already seen it."
> 
> I realize that chef converges such that recipes don't get loaded twice,  
> but I'm  
> not sure how to reconcile that convergence with the results that I'm  
> after. Is  
> there a way to invoke the loaded recipe a second time (with different  
> data)?  
> Is my model/understanding flawed? Am I doing it wrong?
> 
> I did come across this old bug which describes a similar problem, but the  
> workaround doesn't seem to work anymore and the proper solution isn't very  
> clear (to a newbie).
> 
> [https://tickets.opscode.com/browse/CHEF-1406](https://tickets.opscode.com/browse/CHEF-1406)
> 
> Thanks in advance for any constructive advice.
