bryanwb/chef-jmxtrans — pull request #14 by anatolijd (2014-03-18 15:15:22+00:00)
Title: work around 'Exception::ImmutableAttributeModification'

Running this recipe under chef-11.8.0 I get this:

```
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"'

Cookbook Trace:
---------------
/var/chef/cache/cookbooks/jmxtrans/recipes/default.rb:23:in `block in from_file'
/var/chef/cache/cookbooks/jmxtrans/recipes/default.rb:22:in `each'
/var/chef/cache/cookbooks/jmxtrans/recipes/default.rb:22:in `from_file'

Relevant File Content:
----------------------
/var/chef/cache/cookbooks/jmxtrans/recipes/default.rb:

16: end
17:
18: user node['jmxtrans']['user']
19:
20: # merge stock jvm queries w/ container specific ones into single array
21: servers = node['jmxtrans']['servers']
22: servers.each do |server|
23>> server['queries'] = node['jmxtrans']['default_queries']['jvm']
24: case server['type']
25: when 'tomcat'
26: server['queries'] << node['jmxtrans']['default_queries']['tomcat']
27: end
28: server['queries'].flatten!
29: end
30:
31: ark "jmxtrans" do
32: url node['jmxtrans']['url']
```

Since it is the only place where we refer to node['jmxtrans']['servers'] attribute in recipe - .dup can be used to work it around (I hope).