The best way probably
knife exec -E "nodes.find(:name => 'chef-node') { |node| node.normal_attrs['some_key'] = 'some_value'; node.save; }"
Unofficial gem: https://github.com/pdf/knife-attribute
- Create a script editor.rb:
#!/usr/bin/env ruby
require 'json'
data = JSON.parse(File.read(ARGV[0]))
# You can read data from other json file on disk and
# add key=value as attribute
data['normal']['some_key'] = 'some_data'
File.write(ARGV[0], JSON.pretty_generate(data))
-
Set the $EDITOR variable :
export EDITOR=./path/to/editor.rb
-
Run knife command:
knife node edit chef-node