# Rebuild my chef!

**URL:** <https://discourse.chef.io/t/rebuild-my-chef/4050>\
**Category:** Chef Infra (archive)\
**Created:** [May 6, 2013, 4:38pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050 "2013-05-06T16:38:32Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jorge\_Espada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jorge_espada/32/267_2.png) [@Jorge\_Espada](https://discourse.chef.io/u/Jorge_Espada)\
**Post date:** [May 6, 2013, 4:38pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/1 "2013-05-06T16:38:32Z")

</div>

Ohai Chefs!

At my org we still have a monolithic chef-repo, with very little testing…  
lets say the old way, being said that  
I’m looking for advice/comments on how to rebuild this. Things that I think  
are no brainer:

- Have a chef server per environment: hosted chef for prod, ideally will be  
good to have for the others env too, but monay is the constrain here so OS  
for non prod env
- Use a git repo per cookbook
- use berkshelf
- test all the things (foodcritic, test-kitchen, chef-spec, mini-test)

Still I can’t decide what to do with environment regarding cookbooks, have  
a branch per environment, like master(prod), test, dev or use  
another method

Any other comments, ideas, recommendations are welcome

Thanks for being an awesome community 🙂

–  
Jorge Espada

---

<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:** [May 6, 2013, 4:55pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/2 "2013-05-06T16:55:49Z")

</div>

This is what i'd do:

1. integrate berkshelf
2. Wont split t e cookbooks into separate repos
3. Move the cookbook that's takes from community to a separate dir from  
org specific cookbooks  
4)chances are high the community cookbooks are modified, identify them,  
port them to separate wrapper cookbooks or something else (and write  
chefspec tests against them)
4. Once step 4 is done get rid the community cookbook dir completely
5. Setup test-kitchen/minitest against the org specific staff

On Mon, May 6, 2013 at 9:38 AM, Jorge Espada [espada.jorge@gmail.com](mailto:espada.jorge@gmail.com) wrote:

> Ohai Chefs!
> 
> At my org we still have a monolithic chef-repo, with very little testing..  
> lets say the old way, being said that  
> I'm looking for advice/comments on how to rebuild this. Things that I  
> think are no brainer:
> 
> - Have a chef server per environment: hosted chef for prod, ideally will  
> be good to have for the others env too, but monay is the constrain here so  
> OS for non prod env
> - Use a git repo per cookbook
> - use berkshelf
> - test all the things (foodcritic, test-kitchen, chef-spec, mini-test)
> 
> Still I can't decide what to do with environment regarding cookbooks, have  
> a branch per environment, like master(prod), test, dev or use  
> another method
> 
> Any other comments, ideas, recommendations are welcome
> 
> Thanks for being an awesome community 🙂
> 
> --  
> Jorge Espada

---

<div class="post-metadata">

**Author:** ![Jeremy\_Voorhis](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/jeremy_voorhis/32/552_2.png) [@Jeremy\_Voorhis](https://discourse.chef.io/u/Jeremy_Voorhis)\
**Post date:** [May 6, 2013, 5:00pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/3 "2013-05-06T17:00:09Z")

</div>

Having undertaken a similar endeavor, I'll share one trick that worked for  
me:

If you're not already using a site-cookbooks directory, create one and move  
all of your existing cookbooks into it. (You may need to reconfigure your  
knife.rb.) Now, you can split each cookbook into its own repo and manage it  
with Berkshelf.

On Mon, May 6, 2013 at 9:38 AM, Jorge Espada [espada.jorge@gmail.com](mailto:espada.jorge@gmail.com) wrote:

> Ohai Chefs!
> 
> At my org we still have a monolithic chef-repo, with very little testing..  
> lets say the old way, being said that  
> I'm looking for advice/comments on how to rebuild this. Things that I  
> think are no brainer:
> 
> - Have a chef server per environment: hosted chef for prod, ideally will  
> be good to have for the others env too, but monay is the constrain here so  
> OS for non prod env
> - Use a git repo per cookbook
> - use berkshelf
> - test all the things (foodcritic, test-kitchen, chef-spec, mini-test)
> 
> Still I can't decide what to do with environment regarding cookbooks, have  
> a branch per environment, like master(prod), test, dev or use  
> another method
> 
> Any other comments, ideas, recommendations are welcome
> 
> Thanks for being an awesome community 🙂
> 
> --  
> Jorge Espada

--  
Jeremy Voorhis

---

<div class="post-metadata">

**Author:** ![Andrew\_Gross](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/andrew_gross/32/320_2.png) [@Andrew\_Gross](https://discourse.chef.io/u/Andrew_Gross)\
**Post date:** [May 6, 2013, 5:08pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/4 "2013-05-06T17:08:45Z")

</div>

Regarding how to manage cookbooks in environments.

1. I would NOT use a different branch for staging vs prod chef  
environments.

It is too easy to push the wrong one to the wrong place. Our solution is  
to just use master branch for a cookbook and upload versions to  
prod/staging as needed. All cookbook versions are locked in environments  
with --freeze so that we are forced to use good versioning practices when  
uploading.

Write a simple wrapper script to upload a cookbook to staging or prod.  
Also, check out knife-spork for workflow help.

On Mon, May 6, 2013 at 1:00 PM, Jeremy Voorhis [jvoorhis@gmail.com](mailto:jvoorhis@gmail.com) wrote:

> Having undertaken a similar endeavor, I'll share one trick that worked for  
> me:
> 
> If you're not already using a site-cookbooks directory, create one and  
> move all of your existing cookbooks into it. (You may need to reconfigure  
> your knife.rb.) Now, you can split each cookbook into its own repo and  
> manage it with Berkshelf.
> 
> On Mon, May 6, 2013 at 9:38 AM, Jorge Espada [espada.jorge@gmail.com](mailto:espada.jorge@gmail.com)wrote:
> 
> > Ohai Chefs!
> > 
> > At my org we still have a monolithic chef-repo, with very little  
> > testing.. lets say the old way, being said that  
> > I'm looking for advice/comments on how to rebuild this. Things that I  
> > think are no brainer:
> > 
> > - Have a chef server per environment: hosted chef for prod, ideally will  
> > be good to have for the others env too, but monay is the constrain here so  
> > OS for non prod env
> > - Use a git repo per cookbook
> > - use berkshelf
> > - test all the things (foodcritic, test-kitchen, chef-spec, mini-test)
> > 
> > Still I can't decide what to do with environment regarding cookbooks,  
> > have a branch per environment, like master(prod), test, dev or use  
> > another method
> > 
> > Any other comments, ideas, recommendations are welcome
> > 
> > Thanks for being an awesome community 🙂
> > 
> > --  
> > Jorge Espada
> 
> --  
> Jeremy Voorhis

---

<div class="post-metadata">

**Author:** ![Maxime\_Brugidou](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/maxime_brugidou/32/55_2.png) [@Maxime\_Brugidou](https://discourse.chef.io/u/Maxime_Brugidou)\
**Post date:** [May 6, 2013, 8:45pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/5 "2013-05-06T20:45:01Z")

</div>

We plan to completely separate prod environment from the other environments  
using a separate chef server. This is because we want a full automated sync  
between git and chef, and we update roles/nodes regularly (difficult to  
version). I'd love to find a better/proper way to enforce this but this  
solution works quite well: you develop in a regular git workflow and when  
you decide to "release" some automated bot will synchronize the new  
prod/master/release branch with Chef.

In addition, as our teams working with chef get bigger we will also "split"  
chef servers into multiple organizations (multiple chef servers since there  
is no permission system). We have talks about having a central reporting  
database probably a bunch of scripts will suffice for now to query all chef  
instances.  
On May 6, 2013 7:09 PM, "Andrew Gross" [andrew@yipit.com](mailto:andrew@yipit.com) wrote:

> Regarding how to manage cookbooks in environments.
> 
> 1. I would NOT use a different branch for staging vs prod chef  
> environments.
> 
> It is too easy to push the wrong one to the wrong place. Our solution is  
> to just use master branch for a cookbook and upload versions to  
> prod/staging as needed. All cookbook versions are locked in environments  
> with --freeze so that we are forced to use good versioning practices when  
> uploading.
> 
> Write a simple wrapper script to upload a cookbook to staging or prod.  
> Also, check out knife-spork for workflow help.
> 
> On Mon, May 6, 2013 at 1:00 PM, Jeremy Voorhis [jvoorhis@gmail.com](mailto:jvoorhis@gmail.com) wrote:
> 
> > Having undertaken a similar endeavor, I'll share one trick that worked  
> > for me:
> > 
> > If you're not already using a site-cookbooks directory, create one and  
> > move all of your existing cookbooks into it. (You may need to reconfigure  
> > your knife.rb.) Now, you can split each cookbook into its own repo and  
> > manage it with Berkshelf.
> > 
> > On Mon, May 6, 2013 at 9:38 AM, Jorge Espada [espada.jorge@gmail.com](mailto:espada.jorge@gmail.com)wrote:
> > 
> > > Ohai Chefs!
> > > 
> > > At my org we still have a monolithic chef-repo, with very little  
> > > testing.. lets say the old way, being said that  
> > > I'm looking for advice/comments on how to rebuild this. Things that I  
> > > think are no brainer:
> > > 
> > > - Have a chef server per environment: hosted chef for prod, ideally will  
> > > be good to have for the others env too, but monay is the constrain here so  
> > > OS for non prod env
> > > - Use a git repo per cookbook
> > > - use berkshelf
> > > - test all the things (foodcritic, test-kitchen, chef-spec, mini-test)
> > > 
> > > Still I can't decide what to do with environment regarding cookbooks,  
> > > have a branch per environment, like master(prod), test, dev or use  
> > > another method
> > > 
> > > Any other comments, ideas, recommendations are welcome
> > > 
> > > Thanks for being an awesome community 🙂
> > > 
> > > --  
> > > Jorge Espada
> > 
> > --  
> > Jeremy Voorhis

---

<div class="post-metadata">

**Author:** ![Brian\_Akins](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brian_akins/32/298_2.png) [@Brian\_Akins](https://discourse.chef.io/u/Brian_Akins)\
**Post date:** [May 6, 2013, 11:43pm UTC](https://discourse.chef.io/t/rebuild-my-chef/4050/6 "2013-05-06T23:43:55Z")

</div>

We follow semver and tag each version. dev/prod/etc are done using wrapper  
cookbooks with versions specified in metadata.rb (you could do same with  
environments, but you can’t version environments…) If we need to do a fix  
to an older version, then we can check out the tag, make a feature branch,  
pull request, etc and then release a bug fixed cookbook.

Note: I whitewashed a lot, but the above is our ideal - treat a cookbook  
like a normal “library”
