Reputation: 251
My requirement is create a dynamic attribute in chef cookbooks. I declared an default attribute in my recipe like below.
default['servicename']['arf'] = "1"
Sometimes, this value needs to be changed to 2 in some of the nodes. How do we pass this value to cookbooks in run-time??
Upvotes: 1
Views: 898
Reputation: 479
For the rare case, dump it in as a json snippet during invocation.
chef-client -j '<(echo \{\"servicename\":\{\"arf\":\"1\"\}\})' --no-fork
Upvotes: 0
Reputation: 86
you can create a json file as below consider example.json
{
"servicename":{
"arf": 2
}
}
and pass it during chef-client execution as below chef-client -j example.json
Upvotes: 1
Reputation: 54211
It depends on if there are patterns in how it is set. The simplest way is probably to make a Chef role with that value in the role's attributes, and then add it to the run list of any relevant node. You can also set it in the node directly via knife node edit
or similar, or via a Chef environment if it's something that varies by env.
Upvotes: 1