[chef] Re: Re: Re: Re: Tomcat Cookbook and Oracle JDK


Chronological Thread 
  • From: Douglas Garstang < >
  • To:
  • Subject: [chef] Re: Re: Re: Re: Tomcat Cookbook and Oracle JDK
  • Date: Thu, 11 Dec 2014 09:12:59 -0800

Further to this, I could put the setting:

node.override['slice-tomcat']['java_tier_options'] =

in the top level cookbook's attributes file. Presumably then, when it includes the next one in the stack, the value would be set and all would be ok. However, the value of this setting itself is calculated from the instance type. This means I can't put this in the attributes file. It has to go in the recipe. Therefore, if it has to go in the recipe of the top level cookbook, it also has to go in the recipe of the included cookbook. Now we're being forced to avoid usage of the attributes files and we have a big mess.

Doug.


On Thu, Dec 11, 2014 at 9:03 AM, Douglas Garstang < " target="_blank"> > wrote:
Ah yes, the dreaded two phase compile thing that forces you to modify your code to operate in a way that makes not much sense.

I'm already seeing this. My top level tomcat application cookbook set an attribute:

node.override['slice-tomcat']['java_tier_options'] = " -Xms#{jvm_heap_min}M -Xmx#{jvm_heap_max}M -Djava.awt.headless=true"

In it's recipe, it then included the slice-tomcat (wrapper for tomcat) recipe, and in it's attributes file it has:

default['tomcat']['java_options'] = "${JAVA_OPTS} -Dcom.sun.management.jmxremote"
default['tomcat']['java_options'] += " -Dcom.sun.management.jmxremote.port=9010"
default['tomcat']['java_options'] += " -Dcom.sun.management.jmxremote.rmi.port=9010"
default['tomcat']['java_options'] += " -Dcom.sun.management.jmxremote.authenticate=false"
default['tomcat']['java_options'] += " -Dcom.sun.management.jmxremote.ssl=false"
default['tomcat']['java_options'] += node['slice-tomcat']['java_tier_options']


which fails because node['slice-tomcat']['java_tier_options'] isn't set, presumably because it's operating only on attributes, and since ['slice-tomcat']['java_tier_options'] is set in a recipe, it hasn't been set yet.

Well, I might as well just do away with attributes files all together then. Why bother? I'm now forced into putting attributes into recipes, which probably isn't the right way, but what is the alternative?

Doug.

On Thu, Dec 11, 2014 at 12:47 AM, Tensibai < " target="_blank"> > wrote:

Le 2014-12-11 00:10, Douglas Garstang a écrit :

Well, this is weird.

Someone else replied before Eric and now that reply has disappeared. His suggestion, well I was going to follow it, and it's gone poof. Where did it go?

I'm confused. The java cookbook in one place says if you want the oracle java to include the 'oracle' recipe. Further down, it says to use attributes. Which is it?

It's also not clear now, and never has been, if setting default['java']['install_flavor'] = 'oracle' in my wrapper cookbook will have an effect on a cookbook two levels away in the stack. Ie if I have A -> B -> C and cookbook A has default['java']['install_flavor'] = 'oracle'... will that affect how cookbook B operates?

Doug.


To answer on the 2 levels away: yes.

I'll try to give an exemple:
Cookbook A depends on cookbook B wich in turns edpends on cookbook C.
Chef run will load attributes (which is a common hash for all cookbooks) from C then B then A, so values in A will override thoose in C.

After that the recipe will be compiled.
For the Java cookbook it will do (from default.rb):

include_recipe
"java::#{node['java']['install_flavor']}"

So it will include the correct recipe from the attribute value.

Once the compilation is done, chef will enter the converge phase and act on resources, setting them in the desired state (downloading jave, etc)

Hope it helps understanding how it works ;)

More details on the chef run phases here: http://docs.chef.io/chef_client.html#the-chef-client-title-run
One of the ticket about this ordering is solved by https://github.com/opscode/chef/pull/508 I can't find doc or a blog post about how the run_list is expanded :/


On Wed, Dec 10, 2014 at 1:06 PM, Eric Helgeson < " target="_blank"> > wrote:
Yep, you can, take a look at the examples in the readme - https://github.com/agileorbit-cookbooks/java/#examples

Just override some attributes and it will install that version.
 
Also be sure to mirror the oracle binary locally in production, as downloading directly can be troublesome at times https://github.com/agileorbit-cookbooks/java#production-deployment-with-oracle-java
 
-Eric
 

On Wed Dec 10 2014 at 2:32:05 PM Douglas Garstang < " target="_blank"> > wrote:
I was taking a look at the tomcat cookbook for chef, https://github.com/opscode-cookbooks/tomcat.

It installs the OpenJDK. It doesn't seem to have a facility to change that to the Oracle JDK. I look a look inside the tomcat recipe and yep, it's got:

include_recipe "java"

The java cookbook can install the Oracle JDK, but the defaut installs the OpenJDK. Is there a way I can override this without modifying the java or tomcat cookbooks?

Doug



--

 

 



--



--



Archive powered by MHonArc 2.6.16.

§