[chef] Re: environment includes? role includes? run list in the environment?


Chronological Thread 
  • From: Peter Donald < >
  • To:
  • Subject: [chef] Re: environment includes? role includes? run list in the environment?
  • Date: Thu, 28 Feb 2013 12:03:14 +1100

Hi,

IMHO you are doing it wrong. :) (See [1])

We have the exact same problem. Different data centers require
different runlists and/or configuration. When presented with the
prospect of doing logic that may require evolution/versioning I tend
to see that the best place to do that in chef atm is in a cookbook.

So we typically will do the logic in such a big switch or decision
tree of some type. Our nameservers are not chef managed so they are a
bunch of static configurations and we have something like the
following in a recipe in our base cookbook.

if '8ND' == node['datacenter']
  node.override['resolver']['nameservers'] = ["X.X.X.X"]
elsif 'BWD' == node['datacenter']
  node.override['resolver']['nameservers'] = ["X.X.X.X", "X.X.X.X"]
....
elsif 'VAGRANT' == node['datacenter']
  node.override['resolver']['nameservers'] = ["10.61.69.22", "10.61.69.23"]
else
  raise "Unknown datacenter #{node['datacenter']}"
end

We also use this approach to decide whether or not to include certain recipes.

At other times we use search to derive the configuration and then
limit the criteria by environment/datacenter.

HTH

[1] 
http://realityforge.org/code/2012/11/19/role-cookbooks-and-wrapper-cookbooks.html

On Thu, Feb 28, 2013 at 11:50 AM, Jesse Campbell 
< >
 wrote:
> I want to have a "base" role and automatically include a datacenter-specific
> role depending on the environment.
>
> essentially i have:
>
> datacenter 1 (primary production):
> 10 environments
>
> datacenter 2 (international):
> 6 environments
>
> datacenter 3 (development):
> 6 environments
>
> i have a "base" role that includes all of the recipes and roles and
> attributes that are common to all of the above as well as specific to DC1
>
> then i have attribute overrides in the other 12 environments to fix things
> that are specific to DC2 or DC3.
>
> i could use environment run lists, but then i'd have to list the 15 recipes
> that are in the default run list 22 times. yuck.
>
> is there any way to specify a run list in the environment file instead? any
> other ideas?
>
> thanks!



-- 
Cheers,

Peter Donald



Archive powered by MHonArc 2.6.16.

§