How to set Node Attributes on a Chef Client?

寵の児 提交于 2019-12-01 21:21:42
PatrickWalker

Both the above work or you can create them in recipes using something like

Node[attribute_name]

To keep with your json functionality you could leverage attributes or tags

to add attributes use something like this in your json file that you're generating. The attribute name and value can be generated in your script by parameters or csv/xml input

{

    "test_attribute" : "testvalue"
}

In the example you've linked to they are setting attributes under a chef-client hash

"chef_client": {
 "server_url": "http://ec2-23-20-173-176.compute-1.amazonaws.com:4000",
 "interval": "20"
}

Those attributes are created as normal node attributes and would be accessed by node["chef_client"]["interval"] for example.

Does that make sense?

Either give the client a role and add attributes there or pass a .json file containing node data using the -j parameter of chef-client.

Lets say you want to add the recipe mouse to your node target1.

knife node run_list add target1 "recipe[mouse]"

It should work with all the attributes.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!