How to pass attributes in chef-client without JSON file?

非 Y 不嫁゛ 提交于 2020-01-12 01:50:16

问题


I know we can pass node attributes in chef-{client/solo} with --json-attributes(-j) flag. This flag always expect a JSON file as input. Is their any method I can directly pass the attributes as JSON objects.

I tried doing it. For eg:

chef-client -j {"attr":"value"} 

But it ends up with a failure message as:

FATAL: I cannot find {"attr":"value"}

As it expects a JSON file. I need to pass JSON objects as in our env I can't create a json file. I don't want to use attributes/role/environment files as well. Is there any other way to pass the attributes ?


回答1:


Have you tried piping the JSON to STDIN?

echo '{"attr":"value"}' | chef-client -j /dev/stdin




回答2:


This should work:

knife ssh $VM -- chef-client -j '<(echo \{\"attr\":\"value\"\})' --no-fork

YMMV



来源:https://stackoverflow.com/questions/21986477/how-to-pass-attributes-in-chef-client-without-json-file

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