- From: Noah Kantrowitz <
>
- To:
- Subject: [chef] Re: The Application Cookbook Pattern vs. String / Node Attribute Interpolation in Attributes files
- Date: Mon, 5 Aug 2013 10:52:37 -0700
The usual way to fix this is to put the attribute override in your cookbook's
attribute file and then force Chef to re-execute the java cookbook attributes
file. Unfortunately that snippet is in a ticket so I can't get to it right
now.
--Noah
On Aug 5, 2013, at 9:56 AM, Torben Knerr
<
>
wrote:
>
>
Ohai Chefs,
>
>
given an application cookbook trying to installing Java 7:
>
>
```sample-app/recipes/default.rb
>
node.set['java']['jdk_version'] = "7"
>
include_recipe "java"
>
```
>
>
It will always install Java version 6 because the node attributes from the
>
Java cookbook have already been interpolated when the sample-app recipe is
>
evaluated:
>
>
```java/attributes/default.rb
>
...
>
default['java']['jdk_version'] = '6'
>
...
>
when "debian"
>
...
>
default['java']['openjdk_packages'] =
>
["openjdk-#{node['java']['jdk_version']}-jdk", "default-jre-headless"]
>
...
>
```
>
>
The only way to "correctly" pass in the java/jdk_version attribute is from
>
external, e.g. via environment files or dna.json etc... That works, but
>
actually I consider the JDK version an implementation detail of the
>
application cookbook and don't want to expose it via the above files.
>
>
How can you deal with that?
>
>
Is there a possibility to re-evaluate the attributes file before you
>
`include_recipe` it? And would this be a good idea at all?!?
>
>
Any ideas or workarounds?
>
>
Cheers,
>
Torben
Archive powered by MHonArc 2.6.16.