I was wondering if anyone has an idea how to decently change a single attribute
of a node when that attribute is passed on the command line as an argument for
a knife plugin.
Let’s say the plugin’s name is 'node set_attr’
E.g. if I run
knife node set_attr NODENAME apache.dir "/tmp"
I want to achieve that node[‘apache’][‘dir’] == “/tmp”.
The only way I came up with is something along the lines of:
@nodename = @name_args
@attribute = @name_args
@new_value = @name_args
@node = Chef::Node.load(@nodename)
ruby_command = “@node.” + @attribute + “=” + @new_value
However imo eval’ing this is kind of ugly, are there any better ways?
My actual use case is the creation of encrypted attribute values via  and
applying them directly to a node, however the encryption stuff itself is
trivial. The only thing I am not very happy about* - as mentioned above - is
using eval to set the attribute.
If this is not the right place to ask ruby questions about non-chef-core
related things, I apologize sincerely.
- besides not having tests for the plugin and catching all sorts of errors that