[chef] Re: Organizing cookbooks in a logical way


Chronological Thread 
  • From: Fabien Delpierre < >
  • To: chef < >
  • Subject: [chef] Re: Organizing cookbooks in a logical way
  • Date: Mon, 3 Aug 2015 19:36:23 -0400


So the real question is if this is a project A, so I should create a cookbook A which will use the the listed cookbooks above. Now project B is for client B and will need the same stack should this differentiation be at attributes level or cookbook level?

In general, cookbooks should be re-usable and as generic as possible. In your case, you can create a linuxsecurity cookbook (don't use underscores in cookbook names -- it'll work at first but can cause you grief later when you start creating resources, which is a more advanced topic), an nginx or apache2 cookbook, and a Wordpress or Joomla cookbook. Or instead of creating them, use a community cookbook, if available. You can use Berkshelf to make it easier to manage your dependencies.

Now this is where you have some options. If you foresee that a typical client deployment will be similar from one client to another, you could put together a simple, generic cookbook that includes the three cookbooks created earlier, and you can customize it for each client using environments.
Or, you can create specific cookbooks for each client, that will be mostly similar to the other option I just explained, but less reliant on environments, since you can store client-specific attributes in the attributes/ directory.
 
How to use the role in practice? For example where to map that nodes a.servers.com b.servers.com, c.servers.com are all linux, web server/nginx ?

In my opinion, don't use roles at all. But to answer your question, you don't need to do that mapping at all, you just bootstrap each node using Knife and assign a run list to each of them.

You might want to read this about how to avoid using Chef roles:
http://realityforge.org/code/2012/11/19/role-cookbooks-and-wrapper-cookbooks.html
Note that in the examples, they use node.override['foo']['bar'] but you shouldn't need to do that, just set attributes as you normally would, by adding attribute files to the attributes/ directory.




Archive powered by MHonArc 2.6.16.

§