Java – Chef Java Cookbook – JDK Upgrades

chefjava

I am testing the Chef Java Cookbook to bring our JDK installations under Chef management and I am wondering how to upgrade the JDK, once installed, using the Chef Java cookbook.

Background

In order specify which flavour of Java to use, as well as the version, I have written a wrapper Cookbook, let's call it "java-wrapper" for this question, and put in place attributes to specify which JDK and where to download it from. So, in "java-wrapper/attributes/default.rb" we have

node.normal["java"]["jdk_version"] = "7"
node.normal["java"]["install_flavor"] = "oracle"
node.normal['java']['jdk']['7']['x86_64']['url'] = "http://localmirror/jdk-7u21-linux-x64.tar.gz"
node.normal['java']['jdk']['7']['x86_64']['checksum'] = "thechecksum"

This then successfully installs JDK 7 update 21.

The Issue

If I then update the above attributes to use JDK 7 update 25 the node attributes get updated after the Chef run but the Chef Java cookbook does not "notice" this and the old JDK remains.

How are other folks managing the JDK via chef and pushing out updates? An alternative I am thinking of is to create an RPM (we're on RHEL) and just using a package resource with :upgrade action.

Thanks,

Fred.

Best Answer

It turns out I had forgotten to use "include_recipe java" in the wrapper cookbook. Once I did that then it worked as expected.