[英]How can I modify a node's attributes in a shell script?
I have been editing node's by using knife node edit [node_name] however, I'd like to save some time and write a script that will automate adding an attribute set to many nodes manifests.我一直在使用 knife node edit [node_name] 编辑节点,但是,我想节省一些时间并编写一个脚本,该脚本将自动向许多节点清单添加属性集。
I'd like some way to add the following into the "normal": {} section in a bash script.我想要一些方法将以下内容添加到 bash 脚本中的“正常”:{} 部分。
"borg": {
"client": {
"backup_server_override": "10.140.4.141"
}
},
Is there a command, or way I can do this without using knife node edit, and avoiding the interactive editor?有没有命令,或者我可以在不使用 knife node edit 和避免交互式编辑器的情况下执行此操作?
Check out knife exec
and nodes.transform
, probably will do what you want:查看
knife exec
和nodes.transform
,可能会做你想做的事:
knife exec -E 'nodes.transform ("*:*") {|n| n.normal["whatever"] = "something" }'
WARNING: "*:*"
will grab ALL nodes and applies the transform function to them.警告:
"*:*"
将获取所有节点并将转换函数应用于它们。 Be careful.当心。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.