Search code examples
chef-infrajavachef-recipe

How to use chef to install JDK8 on RHEL


I have been looking at this for help : https://github.com/agileorbit-cookbooks/java. I don't know how to run recipes from this cookbook.

I am completely new to chef.

I have gone through the basic chef tutorial and I know to do this :

chef-apply $recipe.rb

I need help in creating a recipe to install for JDK 7/8. I don't need a cookbook. I have setup the chef-dk on my machine, and tried out a few examples from their learning website.

EDIT#1 :

Looking at the Java-Cookbook, I don't follow the README file. I am unable to run the recipe for JDK-8 install.

What I am trying is as follows :

  • cd into the java cookbook
  • cd into the recipes folder
  • chef-apply $recipe-name.rb
  • this is giving me errors

What I want to do :

  • Install JDK8 using chef from the internet

I have tried the following things listed below :

I try to do this :

chef-apply default.rb

I get the following errors :

FATAL : Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
FATAL : NoMethodError: undefined method '[]' for nil"NilClass

The 'chef-stacktrace.out' contains :

enter image description here


Solution

  • I'm really unsure of where you're stuck, quoting the README for the java cookbook (the link you gave):

    You have to make a wrapper cookbook with:

    • metadata.rb

      [...] # Usual data in a cookbook
      
      depends "java"
      
    • attribute/default.rb

      default["java"]["install_flavor"] = "oracle"
      default["java"]["jdk_version"] = "7"
      default['java']['jdk']['7']['x86_64']['url'] = "http://you_local_host/package.tgz" # Oracle does not allow to directly download the jdk
      
    • recipes/default.rb

      include_recipe "java"
      

    And then add this cookbook to your target runlist.

    Best idea would be to start with the learning material here about what is a runlist and about wrapper cookbooks.