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 can
verify 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