# The Application Cookbook Pattern vs. String / Node Attribute Interpolation in Attributes files

**URL:** <https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362>\
**Category:** Chef Infra (archive)\
**Created:** [August 5, 2013, 4:56pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362 "2013-08-05T16:56:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [August 5, 2013, 4:56pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/1 "2013-08-05T16:56:44Z")

</div>

Ohai Chefs,

given an application cookbook trying to installing Java 7:

```auto
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:

```auto
...
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

---

<div class="post-metadata">

**Author:** ![Joseph\_Holsten](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joseph_holsten/32/69_2.png) [@Joseph\_Holsten](https://discourse.chef.io/u/Joseph_Holsten)\
**Post date:** [August 5, 2013, 5:48pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/2 "2013-08-05T17:48:56Z")

</div>

I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic for a pr to the nexus cookbook: [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)

I attempted a well timed `include_attribute 'java'`, but couldn't make it work.

## If there is a less terrible way, I'd love to know.

~j

On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:

> Ohai Chefs,
> 
> given an application cookbook trying to installing Java 7:
> 
> ```auto
> 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:
> 
> ```auto
> ...
> 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

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [August 5, 2013, 5:52pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/3 "2013-08-05T17:52:37Z")

</div>

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 [ukio@gmx.de](mailto:ukio@gmx.de) wrote:

> Ohai Chefs,
> 
> given an application cookbook trying to installing Java 7:
> 
> ```auto
> 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:
> 
> ```auto
> ...
> 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

---

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [August 6, 2013, 2:18pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/4 "2013-08-06T14:18:35Z")

</div>

On Mon, Aug 5, 2013 at 7:52 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

> 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.

Oh, that sounds good. I'd be highly interested in how to do that and the  
ticket you mentioned.

Cheers, Torben

---

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [August 6, 2013, 2:30pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/5 "2013-08-06T14:30:45Z")

</div>

I also played around with `include_attribute` in the recipe, in the  
attributes file etc. but couldn't make it work. I also tried renaming my  
application cookbook and attribute files so that they come alphabetically  
before "java", but that didn't make any difference too (surely because of  
the `include_recipe "java"`).

I'm looking forward to the workaround mentioned by Noah, couldn't find it  
via Google so far.

Btw: have you considered forking and "fixing" the Java cookbook rather than  
duplicating the attributes logic?

On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten [joseph@josephholsten.com](mailto:joseph@josephholsten.com)wrote:

> I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic for  
> a pr to the nexus cookbook:  
> [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> 
> I attempted a well timed `include_attribute 'java'`, but couldn't make it  
> work.
> 
> ## If there is a less terrible way, I'd love to know.
> 
> ~j
> 
> On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> 
> > Ohai Chefs,
> > 
> > given an application cookbook trying to installing Java 7:
> > 
> > ```auto
> > 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:
> > 
> > ```auto
> > ...
> > default['java']['jdk_version'] = '6'
> > ...
> > when "debian"
> > ...
> > default['java']['openjdk_packages'] =
> > 
> > ```
> 
> ["openjdk-#{node['java']['jdk\_version']}-jdk", "default-jre-headless"]
> 
> > ...
> > 
> > ```auto
> > 
> > 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

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [August 6, 2013, 5:46pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/6 "2013-08-06T17:46:13Z")

</div>

Now that Jira is back, just add this to the bottom of your attributes file: node.from\_file(run\_context.resolve\_attribute(\*parse\_attribute\_file\_spec("java")))

--Noah

On Aug 6, 2013, at 7:30 AM, Torben Knerr wrote:

> I also played around with `include_attribute` in the recipe, in the attributes file etc. but couldn't make it work. I also tried renaming my application cookbook and attribute files so that they come alphabetically before "java", but that didn't make any difference too (surely because of the `include_recipe "java"`).
> 
> I'm looking forward to the workaround mentioned by Noah, couldn't find it via Google so far.
> 
> Btw: have you considered forking and "fixing" the Java cookbook rather than duplicating the attributes logic?
> 
> On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten [joseph@josephholsten.com](mailto:joseph@josephholsten.com) wrote:  
> I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic for a pr to the nexus cookbook: [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> 
> I attempted a well timed `include_attribute 'java'`, but couldn't make it work.
> 
> ## If there is a less terrible way, I'd love to know.
> 
> ~j
> 
> On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> 
> > Ohai Chefs,
> > 
> > given an application cookbook trying to installing Java 7:
> > 
> > ```auto
> > 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:
> > 
> > ```auto
> > ...
> > 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

---

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [August 6, 2013, 6:08pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/7 "2013-08-06T18:08:13Z")

</div>

Thanks, that works!

I'm using a slightly modified variant now which I find a bit more readable:  
`node.from_file(run_context.resolve_attribute("java", "default"))`

Found the hint here:  
[http://docs.opscode.com/chef/essentials\_cookbook\_recipes.html#reload-attributes](http://docs.opscode.com/chef/essentials_cookbook_recipes.html#reload-attributes)

Btw: mind posting the link to the Jira issue?

Cheers, Torben

On Tue, Aug 6, 2013 at 7:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

> Now that Jira is back, just add this to the bottom of your attributes  
> file:  
> node.from\_file(run\_context.resolve\_attribute(\*parse\_attribute\_file\_spec("java")))
> 
> --Noah
> 
> On Aug 6, 2013, at 7:30 AM, Torben Knerr wrote:
> 
> > I also played around with `include_attribute` in the recipe, in the  
> > attributes file etc. but couldn't make it work. I also tried renaming my  
> > application cookbook and attribute files so that they come alphabetically  
> > before "java", but that didn't make any difference too (surely because of  
> > the `include_recipe "java"`).
> > 
> > I'm looking forward to the workaround mentioned by Noah, couldn't find  
> > it via Google so far.
> > 
> > Btw: have you considered forking and "fixing" the Java cookbook rather  
> > than duplicating the attributes logic?
> > 
> > On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten [joseph@josephholsten.com](mailto:joseph@josephholsten.com)  
> > wrote:  
> > I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic  
> > for a pr to the nexus cookbook:  
> > [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> > 
> > I attempted a well timed `include_attribute 'java'`, but couldn't make  
> > it work.
> > 
> > ## If there is a less terrible way, I'd love to know.
> > 
> > ~j
> > 
> > On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> > 
> > > Ohai Chefs,
> > > 
> > > given an application cookbook trying to installing Java 7:
> > > 
> > > ```auto
> > > 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:
> > > 
> > > ```auto
> > > ...
> > > default['java']['jdk_version'] = '6'
> > > ...
> > > when "debian"
> > > ...
> > > default['java']['openjdk_packages'] =
> > > 
> > > ```
> 
> ["openjdk-#{node['java']['jdk\_version']}-jdk", "default-jre-headless"]
> 
> > > ...
> > > 
> > > ```auto
> > > 
> > > 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

---

<div class="post-metadata">

**Author:** ![coderanger](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/coderanger/32/5_2.png) [@coderanger](https://discourse.chef.io/u/coderanger)\
**Post date:** [August 6, 2013, 6:09pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/8 "2013-08-06T18:09:59Z")

</div>

[http://tickets.opscode.com/browse/CHEF-4234](http://tickets.opscode.com/browse/CHEF-4234)

--Noah

On Aug 6, 2013, at 11:08 AM, Torben Knerr wrote:

> Thanks, that works!
> 
> I'm using a slightly modified variant now which I find a bit more readable: `node.from_file(run_context.resolve_attribute("java", "default"))`
> 
> Found the hint here:  
> [http://docs.opscode.com/chef/essentials\_cookbook\_recipes.html#reload-attributes](http://docs.opscode.com/chef/essentials_cookbook_recipes.html#reload-attributes)
> 
> Btw: mind posting the link to the Jira issue?
> 
> Cheers, Torben
> 
> On Tue, Aug 6, 2013 at 7:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:  
> Now that Jira is back, just add this to the bottom of your attributes file: node.from\_file(run\_context.resolve\_attribute(\*parse\_attribute\_file\_spec("java")))
> 
> --Noah
> 
> On Aug 6, 2013, at 7:30 AM, Torben Knerr wrote:
> 
> > I also played around with `include_attribute` in the recipe, in the attributes file etc. but couldn't make it work. I also tried renaming my application cookbook and attribute files so that they come alphabetically before "java", but that didn't make any difference too (surely because of the `include_recipe "java"`).
> > 
> > I'm looking forward to the workaround mentioned by Noah, couldn't find it via Google so far.
> > 
> > Btw: have you considered forking and "fixing" the Java cookbook rather than duplicating the attributes logic?
> > 
> > On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten [joseph@josephholsten.com](mailto:joseph@josephholsten.com) wrote:  
> > I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic for a pr to the nexus cookbook: [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> > 
> > I attempted a well timed `include_attribute 'java'`, but couldn't make it work.
> > 
> > ## If there is a less terrible way, I'd love to know.
> > 
> > ~j
> > 
> > On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> > 
> > > Ohai Chefs,
> > > 
> > > given an application cookbook trying to installing Java 7:
> > > 
> > > ```auto
> > > 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:
> > > 
> > > ```auto
> > > ...
> > > 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

---

<div class="post-metadata">

**Author:** ![Torben\_Knerr](https://avatars.discourse-cdn.com/v4/letter/t/ba8739/32.png) [@Torben\_Knerr](https://discourse.chef.io/u/Torben_Knerr)\
**Post date:** [August 6, 2013, 6:17pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/9 "2013-08-06T18:17:30Z")

</div>

Thanks!

On Tue, Aug 6, 2013 at 8:09 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net) wrote:

> [http://tickets.opscode.com/browse/CHEF-4234](http://tickets.opscode.com/browse/CHEF-4234)
> 
> --Noah
> 
> On Aug 6, 2013, at 11:08 AM, Torben Knerr wrote:
> 
> > Thanks, that works!
> > 
> > I'm using a slightly modified variant now which I find a bit more  
> > readable: `node.from_file(run_context.resolve_attribute("java", "default"))`
> > 
> > Found the hint here:
> 
> [http://docs.opscode.com/chef/essentials\_cookbook\_recipes.html#reload-attributes](http://docs.opscode.com/chef/essentials_cookbook_recipes.html#reload-attributes)
> 
> > Btw: mind posting the link to the Jira issue?
> > 
> > Cheers, Torben
> > 
> > On Tue, Aug 6, 2013 at 7:46 PM, Noah Kantrowitz [noah@coderanger.net](mailto:noah@coderanger.net)  
> > wrote:  
> > Now that Jira is back, just add this to the bottom of your attributes  
> > file:  
> > node.from\_file(run\_context.resolve\_attribute(\*parse\_attribute\_file\_spec("java")))
> > 
> > --Noah
> > 
> > On Aug 6, 2013, at 7:30 AM, Torben Knerr wrote:
> > 
> > > I also played around with `include_attribute` in the recipe, in the  
> > > attributes file etc. but couldn't make it work. I also tried renaming my  
> > > application cookbook and attribute files so that they come alphabetically  
> > > before "java", but that didn't make any difference too (surely because of  
> > > the `include_recipe "java"`).
> > > 
> > > I'm looking forward to the workaround mentioned by Noah, couldn't find  
> > > it via Google so far.
> > > 
> > > Btw: have you considered forking and "fixing" the Java cookbook rather  
> > > than duplicating the attributes logic?
> > > 
> > > On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten \<  
> > > [joseph@josephholsten.com](mailto:joseph@josephholsten.com)\> wrote:  
> > > I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic  
> > > for a pr to the nexus cookbook:  
> > > [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> > > 
> > > I attempted a well timed `include_attribute 'java'`, but couldn't make  
> > > it work.
> > > 
> > > ## If there is a less terrible way, I'd love to know.
> > > 
> > > ~j
> > > 
> > > On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> > > 
> > > > Ohai Chefs,
> > > > 
> > > > given an application cookbook trying to installing Java 7:
> > > > 
> > > > ```auto
> > > > 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:
> > > > 
> > > > ```auto
> > > > ...
> > > > default['java']['jdk_version'] = '6'
> > > > ...
> > > > when "debian"
> > > > ...
> > > > default['java']['openjdk_packages'] =
> > > > 
> > > > ```
> 
> ["openjdk-#{node['java']['jdk\_version']}-jdk", "default-jre-headless"]
> 
> > > > ...
> > > > 
> > > > ```auto
> > > > 
> > > > 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

---

<div class="post-metadata">

**Author:** ![Joseph\_Holsten](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/joseph_holsten/32/69_2.png) [@Joseph\_Holsten](https://discourse.chef.io/u/Joseph_Holsten)\
**Post date:** [August 6, 2013, 9:15pm UTC](https://discourse.chef.io/t/the-application-cookbook-pattern-vs-string-node-attribute-interpolation-in-attributes-files/4362/10 "2013-08-06T21:15:38Z")

</div>

\<3 I almost certainly will, eventually. I'm not entirely sure if I want to attempt to fully extract it into a resource/provider. Seems like if I'm going through the effort, I might as well.

On 2013-08-06, at 07:30, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:

> I also played around with `include_attribute` in the recipe, in the attributes file etc. but couldn't make it work. I also tried renaming my application cookbook and attribute files so that they come alphabetically before "java", but that didn't make any difference too (surely because of the `include_recipe "java"`).
> 
> I'm looking forward to the workaround mentioned by Noah, couldn't find it via Google so far.
> 
> Btw: have you considered forking and "fixing" the Java cookbook rather than duplicating the attributes logic?
> 
> On Mon, Aug 5, 2013 at 7:48 PM, Joseph Holsten [joseph@josephholsten.com](mailto:joseph@josephholsten.com) wrote:  
> I just copy-pasta'd the java.java\_home and java.openjdk\_packages logic for a pr to the nexus cookbook: [Use nexus 2.6. Fixes #41. by josephholsten · Pull Request #43 · RiotGamesCookbooks/nexus-cookbook · GitHub](https://github.com/RiotGames/nexus-cookbook/pull/43)
> 
> I attempted a well timed `include_attribute 'java'`, but couldn't make it work.
> 
> ## If there is a less terrible way, I'd love to know.
> 
> ~j
> 
> On 2013-08-05, at 09:56, Torben Knerr [ukio@gmx.de](mailto:ukio@gmx.de) wrote:
> 
> > Ohai Chefs,
> > 
> > given an application cookbook trying to installing Java 7:
> > 
> > ```auto
> > 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:
> > 
> > ```auto
> > ...
> > 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
