- From: Jenn Fountain <
>
- To:
- Subject: [chef] Re: Re: dynamically setting attributes
- Date: Mon, 10 Feb 2014 12:21:35 -0500
Thanks. I did try that but it didn’t work exactly like I wanted.
I tried this piece of code in default.rb:
application = node[:application][:name] default[application][:install][:url] = nil
It seems to work as expected. Thank you!!
On Feb 10, 2014, at 10:26 AM, Mike <
">
> wrote: This sounds like a perfect use case for Chef Environments [1]. In this scenario, you might have an environment file named 'testing.rb' which would contain an attribute defining the environment-specific modifications.
Thereby, associating a node to a particular environment would switch the associated attribute.
Here's a loose example, based on your variables:
# cookbook:
default[:application][:name] = nil
default[:application][:url] = nil
# role myapp.rb: default[:application][:name] = ‘myapp’
# environment testing.rb: default_attributes( "application" => {
} )
# cookbook recipe: default[:myapp][:install][:url] = "http://#{node[: application][:url]}/#{node[:application][:name]}.git"
Hope this helps, -M
|
Archive powered by MHonArc 2.6.16.