Decoupling cookbooks


#1

I’ve been trying to decouple cookbook attributes. At the moment, we have
one role per physical location, ie a data center. Some of the attributes
defined in the role are common to multiple cookbooks (eg: a database server
for example). Since things are still in a state of flux, these attributes
are changing frequently. When the common attribute name changes, it breaks
multiple cookbooks.

I wanted a way to de-couple those attributes, at least for now. I figured
some common ones could maybe be placed back into roles later. I had the
idea I could use environments, where each environment was a physical
location. I was going to put all the attributes for cookbook foo into a
role defined inside the cookbook, and maintained as part of that cookbook.
However, I just realised that updating an environment with the same name
from a different cookbook overwrites the attributes of the previous
cookbook completely.

I suppose a first step could be to move the attributes out of the roles and
into cookbook attributes. However, if I do this I’m not sure what the most
efficient way is to adequately convey each location with the cookbook
attributes. Just use sub keys ?

Doug


#2

Hi,

You could use a common cookbook with different recipes to contain the
attributes relevant to your datacenter(s).
common_cookbook/recipes/
dc1.rb
dc2.rb

-silviu

On Fri, Feb 14, 2014 at 5:37 PM, Douglas Garstang
doug.garstang@gmail.comwrote:

I’ve been trying to decouple cookbook attributes. At the moment, we have
one role per physical location, ie a data center. Some of the attributes
defined in the role are common to multiple cookbooks (eg: a database server
for example). Since things are still in a state of flux, these attributes
are changing frequently. When the common attribute name changes, it breaks
multiple cookbooks.

I wanted a way to de-couple those attributes, at least for now. I figured
some common ones could maybe be placed back into roles later. I had the
idea I could use environments, where each environment was a physical
location. I was going to put all the attributes for cookbook foo into a
role defined inside the cookbook, and maintained as part of that cookbook.
However, I just realised that updating an environment with the same name
from a different cookbook overwrites the attributes of the previous
cookbook completely.

I suppose a first step could be to move the attributes out of the roles
and into cookbook attributes. However, if I do this I’m not sure what the
most efficient way is to adequately convey each location with the cookbook
attributes. Just use sub keys ?

Doug