@jugatsu what you want to do is use hoisting. This will allow you to specify different attributes for different machine deployments. Example can be found is this great presentation https://yolover.poise.io/.
What i have done is create a rb file per machine environment and define just the different attributes. Everything else gets defined at the global level in the Policyfile. I have also defined the environment attributes in different files to make it easier to manage depending on the environment changes the files can get large
@stonesbg thanks for reply. But can you give a little bit more info. You mean using instance_eval(IO.read(‘Policyfile.rb’)) in each node1,node2,node3…node20.rb file?
So what you would do is you would have your main policyfile for example master_policy.rb
Within master_policy.rb you would define your run_list, named_run_list and the default attributes for all instances.
As part of the run_list and named_run_list that you define you need to add the “poise_hoist” cookbook at the very start of the run_list definition.
Then create a folder called env_attributes and in this folder I will create “env1_attributes.rb”. This will be the ruby file that defines all of the default attributes that need to be different for the “env1” environment. You need to make sure that you always specify [‘env1’] as the first attribute for any attributes that you want to override. For example default['env1']['cookbook']['deviceid'] = 12
Now in order to load this file as part of the "chef update " you need to put is these lines:
This will inject the contents of the env1_attributes.rb into the master_policy.rb.
Next you just need to make sure you client.rb has the policy_group defined correctly. Essentially what the poise-hoist cookbook does is it looks at the policy_group your running with “env1” and remove that level of the hierarchy and remaps all values. Therefore you end up with the default[‘env1’][‘cookbook’][‘deviceid’] => default[‘cookbook’][‘deviceid’]