I'm attempting to add some custom code into the opsworks deploy cookbook, related to the before_migrate step:
before_migrate do
link_tempfiles_to_current_release
deploy_version = Time.now.strftime("%Y%m%d%H%M%S")
if node['deploy_app'] == 'web'
link "/var/lib/tomcat#{node["tomcat"]["base_version"]}/webapps/ROOT###{deploy_version}" do
to "#{release_path}"
end
The issue I'm having is when I include the deploy cookbook in my site-cookbook package, I get a chef error:
[2013-08-27T16:45:05+00:00] FATAL: Chef::Exceptions::ImmutableAttributeModification: ruby_block[Compile Custom OpsWorks Run List] (opsworks_custom_cookbooks::execute 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"'
I've verified none of my cookbooks have incorrect node settings, so I'm out of ideas of what the issue could be. I'm finding this error very difficult to debug, and even when I include this cookbook without any modifications, I get this error. Please let me know if you can point me in the right direction.
As of Chef 11, attribute must specify a precedence level. In Chef 10, you could do something like this:
In Chef 11, you must specify the precedence level for that value:
You can also use
default
andoverride
(which correspond to the attribute precedence levels:I suspect the cookbook you are using (or a dependent cookbook) is setting data on the node object using the deprecated syntax.