1

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

sudhishkr
  • 3,318
  • 5
  • 33
  • 55
  • I don't understand what you're asking for at all...You talk about the java cookbook and then say you don't need a cookbook. – Tensibai Apr 01 '15 at 15:41
  • @Tensibai - i am trying to figure out how to run the recipe from java cookbook, once I have downloaded it. Pls help. – sudhishkr Apr 06 '15 at 19:04
  • @Tensibai - I have added an edit, i hope this makes it a little more clear where i am stuck. – sudhishkr Apr 07 '15 at 18:21
  • possible duplicate of [Can the java cookbook be used to install a local copy of oracle java?](http://stackoverflow.com/questions/28776899/can-the-java-cookbook-be-used-to-install-a-local-copy-of-oracle-java) – Mark O'Connor Apr 07 '15 at 19:16

1 Answers1

2

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.

Tensibai
  • 15,557
  • 1
  • 37
  • 57
  • Thanks for the help. Does this mean I have to create another cookbook, and use the java cookbook inside that? Is this the concept of a wrapper? – sudhishkr Apr 07 '15 at 18:22
  • Yes it's the idea, you may modify the original cookbook but it quickly turn into a mess when you want to upgrade it, a wrapper is the best way in my point of view (Google around this, you'll find blog post and examples) – Tensibai Apr 07 '15 at 18:47
  • thanks for the help. I will come back with a comment - if i need more help. Thanks. – sudhishkr Apr 07 '15 at 18:48
  • so the EDIT#1 that I was trying is not the right approach, is the correct? or do you think that should work too. – sudhishkr Apr 07 '15 at 18:49
  • See mark's link, his answer on the other question is far more complete and should help you, but I think you really should practice chef with a more easy task (the Java install involves many things system wide) before to get comfortable with how chef works. Try http://learn.chef.io as a starting point if not already done. – Tensibai Apr 07 '15 at 19:29
  • your response does not really address his issue of install version 8 of the JDK. it is simpler to install version 7 especially if you use the `openjdk` flavor. it exists in the repo for most linux distros. Installing JDK8 is not really in most of them yet. – d4v3y0rk Aug 18 '15 at 22:06
  • @d4v3y0rk See comment just above yours. My answer was targetting the first version of the question. At all it could be deleted and the question marked as duplicate. – Tensibai Aug 19 '15 at 08:13