如何在没有JSON文件的情况下在Chef-Client中传递属性? [英] How to pass attributes in chef-client without JSON file?
问题描述
我知道我们可以使用--json-attributes(-j)标志在Chef- {client / solo}中传递节点属性。
此标志始终期望输入一个JSON文件。是他们的任何方法,我都可以直接将属性作为JSON对象传递。
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.
我尝试这样做。例如:
chef-client -j {"attr":"value"}
但最终失败消息如下:
FATAL: I cannot find {"attr":"value"}
JSON文件。
我需要传递JSON对象,因为在我们的环境中,我无法创建json文件。我也不想使用属性/角色/环境文件。还有其他方法可以传递属性吗?
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 ?
推荐答案
您是否尝试过将JSON传递到STDIN?
Have you tried piping the JSON to STDIN?
echo'{ attr: value}' Chef-client -j / dev / stdin
这篇关于如何在没有JSON文件的情况下在Chef-Client中传递属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!