[chef] Re: Re: Re: The Application Cookbook Pattern vs. String / Node Attribute Interpolation in Attributes files


Chronological Thread 
  • From: Noah Kantrowitz < >
  • To:
  • Subject: [chef] Re: Re: Re: The Application Cookbook Pattern vs. String / Node Attribute Interpolation in Attributes files
  • Date: Tue, 6 Aug 2013 10:46:13 -0700

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 
> < >
>  wrote:
> I just copy-pasta'd the java.java_home and java.openjdk_packages logic for 
> a pr to the nexus cookbook: 
> 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 
> < >
>  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.

§