How to write to a cloned node attribute

Main thing is node['whatever'] is read-only (frozen) and should not be modified. clone does copy this state, so you can’t modify the input of your method.

To modify it you’ll have to call node.default['whatever'] =, node.override['whatever'] = or node.set['whatever'] =.
You’re not giving any clue on how you call this method and why you’re doing things this way, so it’s hard to give an advice on how to tackle the real problem.

Edit after diggin in the code: using .dup instead of clone should work.

ref: https://github.com/chef/chef/blob/master/lib/chef/node/immutable_collections.rb