Reputation: 229
I'm trying to override default cookbook attributes (in this case, attributes for nginx). In my default cookbook attributes I have something like this:
default[:my_nginx_cookbook][:site_name] = 'defaultnginx.site.com'
default[:my_nginx_cookbook][:sites] = {
"default.site.com" => {
default_value1: 'stuff'
default_value2: 'yada yada'
},
"default2.site.com" => {
default_value3: 'even more stuff'
default_value4: 'blah blah'
}
}
I want to override these attributes in the environment where I'm deploying the cookbook (I'll call the environment FOO). In my FOO environment file, I have the following:
override_attributes[:my_nginx_cookbook] = {
site_name: 'myrealnginx.site.com'
}
override_attributes[:my_nginx_cookbook][:sites] = {
'myreal.site.com' => {
real_value1: 'real stuff'
real_value2: 'real yada'
},
"myreal2.site.com" => {
real_value3: 'more real stuff'
real_value4: 'real blah'
}
}
However, when I run chef client on the nginx node, it only creates the default sites. I've had no problem overriding default attributes in other environments. Am I not overriding the defaults correctly in this situation?
Upvotes: 0
Views: 438
Reputation: 54211
In a Chef environment file, you would generally set attribute data like this:
override_attributes({
my_nginx_cookbook: {
site_name: 'myrealnginx.site.com',
sites: {
'myreal.site.com' => {
real_value1: 'real stuff'
real_value2: 'real yada'
},
'myreal2.site.com' => {
real_value3: 'more real stuff'
real_value4: 'real blah'
},
},
})
Upvotes: 0