Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use Chef::Node::ImmutableMash in "attributes" attribute in the machine resource #21

Closed
bsteinfeld opened this issue Mar 19, 2014 · 4 comments
Labels
Type: Bug Doesn't work as expected.
Milestone

Comments

@bsteinfeld
Copy link

For example:

attributes/default.rb:

node["people"]["bob"] = "Bobbert"
node["people"]["stanley"] = "Stanbert"

recipes/example.rb

machine "myserver" do
  attributes node["people"]
end

example.rb will raise the following exception:

Chef::Exceptions::ImmutableAttributeModification: machine[myserver] (example::example line 3) had an error: 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"'

In order to get the code to work you currently need to convert the node["people"] Chef::Node::ImmutableMash to a hash:

recipes/example.rb

machine "myserver" do
  attributes node["people"].to_hash
end
@jkeiser
Copy link
Contributor

jkeiser commented May 31, 2014

Is this still a problem?

@jkeiser jkeiser added the bug label May 31, 2014
@hntd187
Copy link

hntd187 commented Jun 17, 2014

@jkeiser I just tried this and received the same error.

@jkeiser
Copy link
Contributor

jkeiser commented Jun 17, 2014

Thanks! I'll look into it. You tried with the latest chef-metal, yes?

@hntd187
Copy link

hntd187 commented Jun 17, 2014

Yes sir.

@jkeiser jkeiser added this to the 1.0 milestone Aug 19, 2014
@jkeiser jkeiser self-assigned this Feb 26, 2015
@jkeiser jkeiser removed their assignment Feb 26, 2015
tyler-ball added a commit to chef/cheffish that referenced this issue Feb 26, 2015
Allow node attributes to be used as input to new_json / augment_new_json (fixes chef-boneyard/chef-provisioning#21)
@jkeiser jkeiser removed the in review label Feb 26, 2015
@tas50 tas50 added Type: Bug Doesn't work as expected. and removed Bug labels Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Doesn't work as expected.
Development

No branches or pull requests

4 participants