Reputation: 123
I can override default attributes in my recipes\roles but I am unable to get any other attributes that are dependant on that attribute to also update.
as an example, for the phantomjs cookbook I want to install 1.9.7 rather than the default 1.9.2. (I know this change has now been committed to the cookbook repo)
I can override the version with:
node.set['phantomjs']['version'] = "1.9.7"
but in the phantomjs default attributes there is a dependant attribute that uses this with string substitution to generate the base url for the download:
default['phantomjs']['basename'] = "phantomjs-#{node['phantomjs']['version']}-linux-#{node['kernel']['machine']}"
Is there a way to set the version attribute so that the change is performed before these dependant attributes are evaluated? Or a way to force a re-evaluation?
This has been a problem I have hit before and in the past I just override everything that is dependant .. but this is not a great approach going forward.
I am using the latest chef (just tested with 11.8.2 under vagrant but latest chef 11.10.4 elsewhere) and using both chef-solo and the chef server.
Thanks.
Upvotes: 5
Views: 1704
Reputation: 607
You need to move your own cookbook (that override this attribute) upper in run list. String interpolation (foo-"#{whatever}"
) executed in compile time (while loading attribute files) and chef-client loads them in order of run list.
Or you have an option to override all dependent attributes manually, but this is road to hell.
Upvotes: 1