本文介绍了运行客户端刀时,编辑对象不变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跑刀客户端修改命令厨师编辑节点设置管理员权限。我想以编程方式做到这一点,所以我的目的是要这个命令添加到shell脚本,如果我可以使它工作。

节点的previous状态(更新

  $刀客户展示-Fj my_node
{
  名:my_node
  PUBLIC_KEY:----- BEGIN PUBLIC KEY ----- \\ n ... ...键\\ n ----- END PUBLIC KEY ----- \\ n
  验证:假的,
  管理员:假的,
  json_class:厨师:: ApiClient
  chef_type:客户端
}

在运行该命令它说,对象是不变,检查与刀客户端节点之后我可以
验证仍然具有ADMIN属性设置为false:

  $刀客户端编辑-d my_node< my_node.json
对象不变,不节能

含量 my_node.json 文件是:

  {
  名:my_node
  PUBLIC_KEY:----- BEGIN PUBLIC KEY ----- \\ n ... ...键\\ n ----- END PUBLIC KEY ----- \\ n
  验证:假的,
  管理员:真实,
  json_class:厨师:: ApiClient
  chef_type:客户端
}

我不知道如何让这件作品。
任何帮助将是非常美联社preciated。

请注意:
    $刀--version
    厨师:12.2.1

更新:我找不到在这个公认的答案thread这是非常相似的。

更新2:我尝试这些其他方面也有完全没有运气(使用同一个JSON文件):

  $猫my_node.json |刀客户端编辑my_node -d
对象不变,不节能$刀客户端编辑my_node -d< my_node.json
对象不变,不节能


解决方案

有你my_node.json和你my_node设置没有区别。改变一个值,然后重试。

I'm running knife client edit command to edit a node in Chef to set admin permissions. I would like to do this programmatically so my intention is to add this command to a shell script if I can make it work.

The previous state of the node is (UPDATE):

$ knife client show -Fj my_node
{
  "name": "my_node",
  "public_key": "-----BEGIN PUBLIC KEY-----\n...key...\n-----END PUBLIC KEY-----\n",
  "validator": false,
  "admin": false,
  "json_class": "Chef::ApiClient",
  "chef_type": "client"
}

When running the command it says that the object is unchanged and after checking the node with knife client I canverify that still has the admin attribute set to false:

$ knife client edit -d my_node < my_node.json
Object unchanged, not saving

The content of my_node.json file is:

{
  "name": "my_node",
  "public_key": "-----BEGIN PUBLIC KEY-----\n...key...\n-----END PUBLIC KEY-----\n",
  "validator": false,
  "admin": true,
  "json_class": "Chef::ApiClient",
  "chef_type": "client"
}

I don't know how to make this piece work.Any help on this will be very much appreciated.

NOTE: $ knife --version Chef: 12.2.1

UPDATE: I couldn't find an accepted answer in this thread which is quite similar.

UPDATE 2: I tried these other ways as well with no luck at all (using same json file):

$ cat my_node.json | knife client edit my_node -d
Object unchanged, not saving

$ knife client edit my_node -d < my_node.json
Object unchanged, not saving
解决方案

There is no difference between your my_node.json and your my_node settings. Change a value and try again.

这篇关于运行客户端刀时,编辑对象不变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:49