I ran into this problem. I also need to set the base variable and set other variables from it, for example:
default["apache"]["apache_docroot"] = '/var/www' #other attributes: default['apache']['webapp1_docroot'] = "#{node['apache']['apache_docroot']/webapp1}"
to get: /var/www/webapp1
As indicated, what happens is that the Chef will find your cookbooks and download their attributes first. Something seems to be wrong. Why not load the parent
override["apache"]["apache_docroot"] = '/net1/websites'
first, then the dependency will work fine. They are lower and will not be overridden.
I found a way around this problem. This is not great, but it works. You end up doing:
- Depends on tomcat * .rb download
- Download parent shell * .rb
- Reboot depends on tomcat specific.rb
You can use this node.from_file command to reload attributes from another file:
puts "*** RUNNING bundle-apache-java-tomcat-example default.rb" # Reload bundle-apache-java-jboss::default attributes to reset var depending on apache_docroot value node.from_file(run_context.resolve_attribute( "bundle-apache-java-tomcat", "default" ) )
this is a cookbook: bundle-apache-java-tomcat, attribs file: default.rb download cookbook: bundle-apache-java-tomcat, attribs file: default.rb
side of the note: I ended up leaving it in my cookbook, but I wanted to set the site attributes in a โsimplerโ way using a hash. I cannot set one attribute from another while I initialize the hash at the same time, but I left this code there in case it might still be needed.
I have created two new cookbooks that I hope make it easy to set up multiple websites. You can also set or not set the proxy link from apache to tomcat.
https://github.com/stant/bundle-apache-java-tomcat-example (how to use the main) https://github.com/stant/bundle-apache-java-tomcat (main)