Add to Node Attribute Hash Value


#1

Ohai Chefs!

I was hoping these two would merge without having to copy the default values from the community cookbook into mine.

Is there a different route to allow the two settings to merge?

The chef-client cookbook sets the following attributes by default:

default[‘chef_client’][‘config’] = {
‘chef_server_url’ => Chef::Config[:chef_server_url],
‘validation_client_name’ => Chef::Config[:validation_client_name],
‘node_name’ => Chef::Config[:node_name] == node[‘fqdn’] ? false : Chef::Config[:node_name]
}

My wrapper cookbook has another value defined in the default attributes file:

default[‘chef_client’][‘config’] = {
‘encrypted_data_bag_secret’ => Chef::Config[:encrypted_data_bag_secret]
}

Thanks,
Curtis


#2

On Wednesday, March 19, 2014 at 7:58 AM, Stewart, Curtis wrote:

Ohai Chefs!

I was hoping these two would merge without having to copy the default values from the community cookbook into mine.

Is there a different route to allow the two settings to merge?

The chef-client cookbook sets the following attributes by default:

default[‘chef_client’][‘config’] = {
‘chef_server_url’ => Chef::Config[:chef_server_url],
‘validation_client_name’ => Chef::Config[:validation_client_name],
‘node_name’ => Chef::Config[:node_name] == node[‘fqdn’] ? false : Chef::Config[:node_name]
}

My wrapper cookbook has another value defined in the default attributes file:

default[‘chef_client’][‘config’] = {
‘encrypted_data_bag_secret’ => Chef::Config[:encrypted_data_bag_secret]
}

Using = to assign a new value here completely replaces the old value. I think the chef-client cookbook is wrong to do this, too, but you can simply add your value by doing:

default[‘chef-client’][‘config’][‘encrypted_data_bag_secret’] = Chef::Config[:encrypted_data_bag_secret]

Thanks,
Curtis


Daniel DeLeo