[chef] Re: Chef Naming conventions


Chronological Thread 
  • From: Fabien Delpierre < >
  • To: chef < >
  • Subject: [chef] Re: Chef Naming conventions
  • Date: Fri, 20 Mar 2015 14:12:32 -0400

Chef doesn't force you to do this kind of thing one way or another. You should aim to write recipes that can be applied to as many systems as possible, and the way Chef is designed can help a lot with that, but it's not always possible. Certainly the differences between OSX and RHEL can warrant having separate recipes, even just for the sake of clarity.
You could just have a single recipe that does something like this (and this isn't real code obviously):

case 'os'
when 'osx'
  do a and b
when 'rhel'
  do c and d
end

do more things that work regardless of the OS

Or you can do something like this in the default recipe:

do foo # this works regardless of the OS
do bar # and so does this

include_recipe "mycookbook::#{node['os']}"

and have a recipe for each OS type you wish your cookbook to support.

https://github.com/L2G/timezone-ii/blob/master/recipes/default.rb is an example of the latter.


On Fri, Mar 20, 2015 at 1:50 PM, michael david mosier < " target="_blank"> > wrote:
What is a good rule of thumb for naming roles, cookbooks, recipes. etc. I noticed we have two recipes both named amanda_installer.rb one for mac and the other is for RHEL. That doesn't sound like that's right. Shouldn't we name things by the os or something so you can tell what it is or is the point to make everything super generic?

 Have a great weekend.

Cheers.

Michael D. Mosier
Systems Guy
University Of Texas
Astro Physics






Archive powered by MHonArc 2.6.16.

§