- From: Joshua Timberman <
>
- To:
- Subject: [chef] Re: Preferred Attribute locations
- Date: Tue, 17 Jul 2012 12:36:11 -0600
Hello,
This topic comes up quite often, and we spend a lot of time discussing this
in our Chef Fundamentals class. There's a number of reasons for the level of
flexibility, most importantly because Chef doesn't know what the right thing
for your systems is, so it provides a lot of options.
The nearest we get to a "best practice" is to use the following guidelines:
* Use "default" attributes in cookbooks' attributes files to set "sane
defaults" such that you do not get a "NilClass" error in your recipes or
templates.
* Use "default_attributes" in roles that are applied to the node(s).
* Use "default" attributes in recipes for values that are calculated, or
might combine other attributes.
* Use "override_attributes" in environments for things that are truly
environment specific (like, use this resolver for DNS in prod, but a
different one in staging).
In general, override attributes should be used sparingly. Consider the kind
of data that your modeling about the node in determining where the attribute
should go.
These aren't set in stone, and you're welcome to modify your use of attribute
setting based on how your infrastructure should be built. You'll probably
find yourself growing out of this fairly narrow set, but probably stick it to
for most things.
Cheers!
Joshua
On Jul 17, 2012, at 7:47 AM, Dylan Northrup wrote:
>
At my day job, we're having a discussion on the proper location for
>
attributes and it was suggested to ask the question on this list to see
>
what the community has to say.
>
>
The assertion initially made was to not use attributes at the Environment
>
level (since there's one and only one Environment per node it is a limiting
>
place to put attributes). The questions that came up from this assertion
>
were as follows:
>
>
- At what level should attributes be set?
>
>
- At the file, role or node level?
>
>
- Does it matter if we're using default, normal/set or override for setting
>
the attributes (other than for precedence's sake)?
>
>
- Also, does the answer change depending on what the particular attribute
>
is?
>
>
- Is there a logical set of attributes that should be defaulted at the role
>
level and overridden at the file level?
>
>
- Or is the usage wide open with the exception of using attributes at the
>
environment level?
>
>
>
Looking at several cookbooks, it appears most cookbooks that have
>
attributes have "default" attributes (with exceptions being relatively old
>
ones). Also, role attributes tend to be "override" attributes. Is this
>
what can be considered "best practice"? Are there cases where this approach
>
is not the preferred approach?
>
>
--
>
Dylan
Archive powered by MHonArc 2.6.16.