# Overriding parts of recipes?

**URL:** <https://discourse.chef.io/t/overriding-parts-of-recipes/1437>\
**Category:** Chef Infra (archive)\
**Created:** [May 31, 2010, 8:55am UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437 "2010-05-31T08:55:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Woolley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/chad_woolley/32/883_2.png) [@Chad\_Woolley](https://discourse.chef.io/u/Chad_Woolley)\
**Post date:** [May 31, 2010, 8:55am UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437/1 "2010-05-31T08:55:29Z")

</div>

I need to override the tomcat6 recipe to disable a single line:

[http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192](http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192)

How should I go about this? I tried this and failed:

1. I have my custom cookbooks in the cookbook\_path after the opscode version
2. I created a ‘tomcat6’ cookbook in my custom cookbooks, which only  
override this single template entry in the default recipe

However, this doesn’t work, because it doesn’t seem to process the  
main opscode version before mine. Is it possible to “merge” them to  
have all the logic from the original with only my override, THEN run  
it?

My only option now seems to be to clone the entire opscode original  
cookbook into my custom cookbooks and disable that one line, which  
seems less than optimal.

Thanks,  
– Chad

P.S. When googling I found this, but it doesn’t answer my problem:  
[http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes](http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes)

---

<div class="post-metadata">

**Author:** ![Ho\_Sheng\_Hsiao](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ho_sheng_hsiao/32/891_2.png) [@Ho\_Sheng\_Hsiao](https://discourse.chef.io/u/Ho_Sheng_Hsiao)\
**Post date:** [May 31, 2010, 6:20pm UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437/2 "2010-05-31T18:20:26Z")

</div>

You could create a site-tomcat6 cookbook in which the recipe there  
include\_recipe(:tomcat) to include it.

I personally would not want to have an implicit merge for cookbooks.

-Hosh

On Mon, May 31, 2010 at 4:55 AM, Chad Woolley [thewoolleyman@gmail.com](mailto:thewoolleyman@gmail.com) wrote:

> I need to override the tomcat6 recipe to disable a single line:
> 
> [http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192](http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192)
> 
> How should I go about this? I tried this and failed:
> 
> 1. I have my custom cookbooks in the cookbook\_path after the opscode version
> 2. I created a 'tomcat6' cookbook in my custom cookbooks, which only  
> override this single template entry in the default recipe
> 
> However, this doesn't work, because it doesn't seem to process the  
> main opscode version before mine. Is it possible to "merge" them to  
> have all the logic from the original with only my override, THEN run  
> it?
> 
> My only option now seems to be to clone the entire opscode original  
> cookbook into my custom cookbooks and disable that one line, which  
> seems less than optimal.
> 
> Thanks,  
> -- Chad
> 
> P.S. When googling I found this, but it doesn't answer my problem:  
> [http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes](http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes)

---

<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:** [May 31, 2010, 6:43pm UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437/3 "2010-05-31T18:43:05Z")

</div>

Ohai!  
We now have support for vendoring cookbooks integrated into knife.  
This lets you maintain your changes to a cookbook as a small patch,  
handled by your SCM (git only for now AFAIK) while still fetching  
changes from the upstream. Have a look at `knife cookbook site vendor`

HTH,  
Dan DeLeo

On Mon, May 31, 2010 at 11:20 AM, Ho-Sheng Hsiao  
[hosheng.hsiao@gmail.com](mailto:hosheng.hsiao@gmail.com) wrote:

> You could create a site-tomcat6 cookbook in which the recipe there  
> include\_recipe(:tomcat) to include it.
> 
> I personally would not want to have an implicit merge for cookbooks.
> 
> -Hosh
> 
> On Mon, May 31, 2010 at 4:55 AM, Chad Woolley [thewoolleyman@gmail.com](mailto:thewoolleyman@gmail.com) wrote:
> 
> > I need to override the tomcat6 recipe to disable a single line:
> > 
> > [http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192](http://github.com/opscode/cookbooks/blob/master/tomcat6/recipes/default.rb#L192)
> > 
> > How should I go about this? I tried this and failed:
> > 
> > 1. I have my custom cookbooks in the cookbook\_path after the opscode version
> > 2. I created a 'tomcat6' cookbook in my custom cookbooks, which only  
> > override this single template entry in the default recipe
> > 
> > However, this doesn't work, because it doesn't seem to process the  
> > main opscode version before mine. Is it possible to "merge" them to  
> > have all the logic from the original with only my override, THEN run  
> > it?
> > 
> > My only option now seems to be to clone the entire opscode original  
> > cookbook into my custom cookbooks and disable that one line, which  
> > seems less than optimal.
> > 
> > Thanks,  
> > -- Chad
> > 
> > P.S. When googling I found this, but it doesn't answer my problem:  
> > [http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes](http://support.scalarium.com/faqs/custom-instance-setup/how-to-override-templates-in-custom-chef-recipes)

---

<div class="post-metadata">

**Author:** ![Chad\_Woolley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/chad_woolley/32/883_2.png) [@Chad\_Woolley](https://discourse.chef.io/u/Chad_Woolley)\
**Post date:** [June 10, 2010, 1:40am UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437/4 "2010-06-10T01:40:47Z")

</div>

On Mon, May 31, 2010 at 11:43 AM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:

> Ohai!  
> We now have support for vendoring cookbooks integrated into knife.  
> This lets you maintain your changes to a cookbook as a small patch,  
> handled by your SCM (git only for now AFAIK) while still fetching  
> changes from the upstream. Have a look at `knife cookbook site vendor`

That sounds useful. It looks like you can only use this approach if  
you use chef server, not just chef solo. Right?

---

<div class="post-metadata">

**Author:** ![Chad\_Woolley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/chad_woolley/32/883_2.png) [@Chad\_Woolley](https://discourse.chef.io/u/Chad_Woolley)\
**Post date:** [June 21, 2010, 5:50am UTC](https://discourse.chef.io/t/overriding-parts-of-recipes/1437/5 "2010-06-21T05:50:00Z")

</div>

On Wed, Jun 9, 2010 at 6:40 PM, Chad Woolley [thewoolleyman@gmail.com](mailto:thewoolleyman@gmail.com) wrote:

> On Mon, May 31, 2010 at 11:43 AM, Daniel DeLeo [dan@kallistec.com](mailto:dan@kallistec.com) wrote:
> 
> > Ohai!  
> > We now have support for vendoring cookbooks integrated into knife.  
> > This lets you maintain your changes to a cookbook as a small patch,  
> > handled by your SCM (git only for now AFAIK) while still fetching  
> > changes from the upstream. Have a look at `knife cookbook site vendor`
> 
> That sounds useful. It looks like you can only use this approach if  
> you use chef server, not just chef solo. Right?

After consideration, I don't want to use Chef Server. It seems like  
unnecessary complexity for my use case, which is just creating  
open-source AMI or VM images. All I want a very simple,  
self-contained script and process which results in a built machine  
which is also self-contained and updatable. To update it in the  
future (which may only happen rarely if it is easy to rebuild), users  
can just update the local cookbook repo via git, and run a single  
command to converge. Just a script or two and the cookbook repo  
required. No servers involved. Everything downloadable/automatable  
via GitHub direct file links. The Simplest Thing That Could Possibly  
Work.

I believe chef-solo is perfect for this use case, and chef server is overkill.

However, I also want to support the chef community by contributing my  
patches and enhancements to the official Opscode cookbooks.

So, it's a bit discouraging that chef-server is a prerequisite for the  
officially recommended solution for managing patches and contributing  
upstream via `knife cookbook site vendor`

I'm managing it on my own for now with git, topic branches for  
patches, and an integration branch for use in my project to merge in  
all patches which are not yet applied upstream. This is a rather  
onerous to do manually, whereas the various `knife cookbook` commands  
sound pretty handy. So, this makes it harder for chef solo users to  
manage, contribute, and update patches.

In theory, it seems like the same flow and commands/api could apply to  
git as well as a chef server: you are just pushing patches to an  
upstream git remote instead of a chef server. Is this an  
over-simplification? Are there other some unknown compelling reasons  
why I really want to be using Chef Server, or would it be good in your  
opinion to add more support for chef-solo as a first class citizen, at  
least in regards to knife and cookbook management/contributions?

Thanks,  
-- Chad
