- From: Lamont Granquist <
>
- To:
- Subject: [chef] Re: Re: Re: Re: Re: Attribute overrides in wrapper cookbook
- Date: Fri, 17 Jan 2014 11:29:19 -0800
Not sure if I'm missing something about your approach, but that is
what I'm talking about doing -- although that example code is
converge-mode and I think its probably better to run it
compile-time, as soon as possible.
On 1/14/14 10:24 PM, Torben Knerr wrote:
"
type="cite">
What about reloading the attributes rather than repeating the
computed one?
http://docs.opscode.com/chef/essentials_cookbook_recipes.html#reload-attributes
On Jan 14, 2014 8:18 PM, "Lamont
Granquist" <
">
>
wrote:
Yeah you can do that. You have to use default attrs in
your library cookbook and override attrs in all
wrapper/role/etc cookbooks, then you roll-your-own
include_attributes to run in the recipe code of your
wrapper/role cookbook and slurp those in as early as
possible. You have to use override attrs or else when you
load the library cookbooks attr file you'll overwrite
everything again. Generally we think that solution has
considerable code smell and isn't going to scale, and is
going down the path that has led us to
force_override/force_default and other hacks added to Chef
to get people out of painting themselves into a corner.
The best practice is generally not to be setting
attributes in recipe code and to move attribute setting
into attribute files in order to get away from
compile/converge issues in recipe code. In simple cases,
though, that does work.
On 1/13/14 6:04 PM, Greg Zapp wrote:
Hi,
Sorry for the short reply. Correct me if I'm
wrong, but looking at the source code, when you get a
attribute key it returns the merged_attributes key?
So, if you were to override version and then use
attribute_resolve to re-load the attributes file on
this line:
default['postgresql']['server']['packages']
= ["postgresql-#{node['postgresql']['version']}"]
It
should get the overridden key for
"node['postgresql']['version'] and work as expected?
-Greg
|
Archive powered by MHonArc 2.6.16.