Kladskull
Kladskull

Reputation: 10752

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.

I'd like some way to add the following into the "normal": {} section in a bash script.

"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?

Upvotes: 0

Views: 768

Answers (1)

coderanger
coderanger

Reputation: 54249

Check out knife exec and nodes.transform, probably will do what you want:

knife exec -E 'nodes.transform ("*:*") {|n| n.normal["whatever"] = "something" }'

WARNING: "*:*" will grab ALL nodes and applies the transform function to them. Be careful.

Upvotes: 2

Related Questions