[chef] Re: Where do YOU put your environment and role files?


Chronological Thread 
  • From: Kent Perrier < >
  • To:
  • Subject: [chef] Re: Where do YOU put your environment and role files?
  • Date: Mon, 9 Mar 2015 13:28:08 -0500

We have a single git repo that contains all of our data bags, environments and roles. It is managed just like our cookbooks.

Kent

On Mon, Mar 9, 2015 at 1:21 PM, Fabien Delpierre < " target="_blank"> > wrote:
When I started working with Chef, I adopted what the guy who was doing this at my company was doing, which was to work with a traditional "Chef repo" checked into GitHub as one monolithic thing, containing all the cookbooks, environments, roles, data bags, etc. But he was doing a lot of things very wrong. I'm also the only person working with Chef here, so I can make changes without really bothering anyone much.

I understand the modern recommendation is to keep your cookbooks in individual git repos, and that's nice. I do most of my development using Vagrant and a Chef provisioner, and as you probably know, you can set the path to your environments or roles in your Vagrantfile.

It bears mentioning that I typically only have a single cookbook in my nodes' run lists, and that single cookbook uses depends in metadata.rb and include_recipe in recipes liberally. I may or may not use environments, and rarely use roles, but sometimes they have a place in what I'm doing.

I could just gut the old Chef repo, removing all the cookbooks and leaving only the environments, roles and data bags, then point my Vagrantfiles to the same paths for those types of resources every time, but most of the time, the environments or roles make no sense except when considered in the context of a given cookbook.

It would make sense (to me at least) to keep them with the cookbook they're meant to be used with, and to put them in the same git repo as the cookbook, but then when I use Berkshelf to create a cookbook, it creates the standard directory structure and it feels weird to me to add a ./environments and a ./roles under my cookbook's directory structure, alongside the ./attributes, ./recipes and so forth.

So does it make more sense to keep the environments and roles in the same git repo as a cookbook, or continue to keep all environments and roles in a central repo, like so:

chef-repo
 |_ cookbooks
     |_ cookbook1
         |_ individual git repo
         |_ Vagrantfile pointed at ../../ for environments and roles
     |_ cookbook2
         |_ individual git repo
         |_ Vagrantfile pointed at ../../ for environments and roles
     |_ etc.
 |_ environments
     |_ all environments ever written
 |_ roles
     |_ all roles ever written
 |_ .gitignore to ignore contents of ./cookbooks

What about data bags? Keep them directly under the repo, or with individual cookbooks? Or both, depending on what makes the most sense?

I know this isn't really a black or white issue, so really I'm just asking for some opinions.




Archive powered by MHonArc 2.6.16.

§