# Recipe subset-ing

**URL:** <https://discourse.chef.io/t/recipe-subset-ing/2016>\
**Category:** Chef Infra (archive)\
**Created:** [August 11, 2011, 1:15am UTC](https://discourse.chef.io/t/recipe-subset-ing/2016 "2011-08-11T01:15:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joaquin\_Casares](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joaquin_casares/32/801_2.png) [@Joaquin\_Casares](https://discourse.chef.io/u/Joaquin_Casares)\
**Post date:** [August 11, 2011, 1:15am UTC](https://discourse.chef.io/t/recipe-subset-ing/2016/1 "2011-08-11T01:15:05Z")

</div>

Hello,

I have cookbook X that calls many functions off of cookbook Y. But my  
attributes for cookbook X are a superset of cookbook Y’s attributes and of  
the values that intersect some are different in cookbook X.

How would I go about doing this correctly?

Right now I call include\_recipe “Y::recipe1” from “X::default”, but it seems  
to overwrite all my X configs that intersect.

Should I just change cookbook X to use override instead of default settings?

Thanks for the help!  
Joaquin

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [August 11, 2011, 4:01pm UTC](https://discourse.chef.io/t/recipe-subset-ing/2016/2 "2011-08-11T16:01:31Z")

</div>

On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:

> Hello,  
> I have cookbook X that calls many functions off of cookbook Y. But my attributes for cookbook X are a superset of cookbook Y's attributes and of the values that intersect some are different in cookbook X.  
> How would I go about doing this correctly?  
> Right now I call include\_recipe "Y::recipe1" from "X::default", but it seems to overwrite all my X configs that intersect.  
> Should I just change cookbook X to use override instead of default settings?  
> Thanks for the help!  
> Joaquin  
> If possible, you should structure your recipes and roles to avoid this situation entirely. If that's not an option, you can use `include_attribute` in an attributes file to force one attributes file to load before another.

--  
Dan DeLeo

---

<div class="post-metadata">

**Author:** ![andi\_abes](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@andi\_abes](https://discourse.chef.io/u/andi_abes)\
**Post date:** [August 11, 2011, 4:07pm UTC](https://discourse.chef.io/t/recipe-subset-ing/2016/3 "2011-08-11T16:07:05Z")

</div>

If you're combined set of code involves mostly collating multiple recipes  
from different cookbooks, you can just create a role, and provide override  
attributes in it:  
[http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes](http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes)

given the precedence order (  
[http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence](http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence)) that  
might just do the trick.

On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:
> 
> > Hello,  
> > I have cookbook X that calls many functions off of cookbook Y. But my  
> > attributes for cookbook X are a superset of cookbook Y's attributes and of  
> > the values that intersect some are different in cookbook X.  
> > How would I go about doing this correctly?  
> > Right now I call include\_recipe "Y::recipe1" from "X::default", but it  
> > seems to overwrite all my X configs that intersect.  
> > Should I just change cookbook X to use override instead of default  
> > settings?  
> > Thanks for the help!  
> > Joaquin  
> > If possible, you should structure your recipes and roles to avoid this  
> > situation entirely. If that's not an option, you can use `include_attribute`  
> > in an attributes file to force one attributes file to load before another.
> 
> --  
> Dan DeLeo

---

<div class="post-metadata">

**Author:** ![Joaquin\_Casares](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joaquin_casares/32/801_2.png) [@Joaquin\_Casares](https://discourse.chef.io/u/Joaquin_Casares)\
**Post date:** [August 11, 2011, 9:46pm UTC](https://discourse.chef.io/t/recipe-subset-ing/2016/4 "2011-08-11T21:46:48Z")

</div>

I went ahead and went with the precendence ordering.

I couldn't do the 'include\_attribute' since the first script I ran need the  
X's attributes already, and it seemed like it would load Y's attributes as  
soon as it ran.

The idea of roles are great, but I really like being able to git control my  
attributes file which I can't do natively with the roles.

Thanks a lot for the suggestions though! I'll definitely keep them in mind  
as I work with Chef further.

Joaquin Casares  
DataStax  
Software Engineer/Support

On Thu, Aug 11, 2011 at 11:07 AM, andi abes [andi.abes@gmail.com](mailto:andi.abes@gmail.com) wrote:

> If you're combined set of code involves mostly collating multiple recipes  
> from different cookbooks, you can just create a role, and provide override  
> attributes in it:  
> [http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes](http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes)
> 
> given the precedence order (  
> [http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence](http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence))  
> that might just do the trick.
> 
> On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:
> 
> > On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:
> > 
> > > Hello,  
> > > I have cookbook X that calls many functions off of cookbook Y. But my  
> > > attributes for cookbook X are a superset of cookbook Y's attributes and of  
> > > the values that intersect some are different in cookbook X.  
> > > How would I go about doing this correctly?  
> > > Right now I call include\_recipe "Y::recipe1" from "X::default", but it  
> > > seems to overwrite all my X configs that intersect.  
> > > Should I just change cookbook X to use override instead of default  
> > > settings?  
> > > Thanks for the help!  
> > > Joaquin  
> > > If possible, you should structure your recipes and roles to avoid this  
> > > situation entirely. If that's not an option, you can use `include_attribute`  
> > > in an attributes file to force one attributes file to load before another.
> > 
> > --  
> > Dan DeLeo

---

<div class="post-metadata">

**Author:** ![andi\_abes](https://avatars.discourse-cdn.com/v4/letter/a/dc4da7/32.png) [@andi\_abes](https://discourse.chef.io/u/andi_abes)\
**Post date:** [August 11, 2011, 10:19pm UTC](https://discourse.chef.io/t/recipe-subset-ing/2016/5 "2011-08-11T22:19:03Z")

</div>

hmmm. why can't you control attributes in a role using git? Can't you save  
the role into a file and manipulate using knife?

On Thu, Aug 11, 2011 at 5:46 PM, Joaquin Casares [joaquin@datastax.com](mailto:joaquin@datastax.com)wrote:

> I went ahead and went with the precendence ordering.
> 
> I couldn't do the 'include\_attribute' since the first script I ran need the  
> X's attributes already, and it seemed like it would load Y's attributes as  
> soon as it ran.
> 
> The idea of roles are great, but I really like being able to git control my  
> attributes file which I can't do natively with the roles.
> 
> Thanks a lot for the suggestions though! I'll definitely keep them in mind  
> as I work with Chef further.
> 
> Joaquin Casares  
> DataStax  
> Software Engineer/Support
> 
> On Thu, Aug 11, 2011 at 11:07 AM, andi abes [andi.abes@gmail.com](mailto:andi.abes@gmail.com) wrote:
> 
> > If you're combined set of code involves mostly collating multiple recipes  
> > from different cookbooks, you can just create a role, and provide override  
> > attributes in it:  
> > [http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes](http://wiki.opscode.com/display/chef/Roles#Roles-overrideattributes)
> > 
> > given the precedence order (  
> > [http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence](http://wiki.opscode.com/display/chef/Attributes#Attributes-Precedence))  
> > that might just do the trick.
> > 
> > On Thu, Aug 11, 2011 at 12:01 PM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:
> > 
> > > On Wednesday, August 10, 2011 at 6:15 PM, Joaquin Casares wrote:
> > > 
> > > > Hello,  
> > > > I have cookbook X that calls many functions off of cookbook Y. But my  
> > > > attributes for cookbook X are a superset of cookbook Y's attributes and of  
> > > > the values that intersect some are different in cookbook X.  
> > > > How would I go about doing this correctly?  
> > > > Right now I call include\_recipe "Y::recipe1" from "X::default", but it  
> > > > seems to overwrite all my X configs that intersect.  
> > > > Should I just change cookbook X to use override instead of default  
> > > > settings?  
> > > > Thanks for the help!  
> > > > Joaquin  
> > > > If possible, you should structure your recipes and roles to avoid this  
> > > > situation entirely. If that's not an option, you can use `include_attribute`  
> > > > in an attributes file to force one attributes file to load before another.
> > > 
> > > --  
> > > Dan DeLeo
