- From: Mark Pimentel <
>
- To:
- Subject: [chef] Merging Hashes
- Date: Wed, 17 Apr 2013 17:27:29 -0400
Just wondering if anyone could help with merging of hashes.
I am attempting to take a given node object and copy it to a hash:
vars = node.test.to_hash
Then I have a data bag with similar keys/values as the node.test object.
{
"id": "mydbag",
"default": {
"var1": "value1",
"var2": "value2"
}
}
So the default in attributes for node.test.var1 = "value_1"
And the data bag is var1 => value1
I want to be able to vars.deep_merge!(dbag["default"]) but every time I try
Chef throws
Chef::Exceptions::ImmutableAttributeModification: Node attributes are
read-only when you do not specify which precedence level to set. To set an
attribute use code like `node.default["key"] = "value"'
vars.class returns Hash as expected and not a node object so why the
Exception?
Any way around this?
- [chef] Merging Hashes, Mark Pimentel, 04/17/2013
Archive powered by MHonArc 2.6.16.