[chef] Re: Re: Re: Java cookbook from the Chef Supermarket


Chronological Thread 
  • From: Jeff Byrnes < >
  • To:
  • Subject: [chef] Re: Re: Re: Java cookbook from the Chef Supermarket
  • Date: Mon, 29 Jun 2015 16:40:03 -0400

Kurt:

You might also, rather than using a role, just set the attributes in your cookbook where you `include_recipe ‘java’`. That’s a simple version of the wrapper cookbook pattern, which will allow you to keep all of your settings together with the cookbook that installs the packages you need.

Starting from your cookbook’s root, you’d have:

attributes/default.rb:

```
set['java']['jdk_version'] = '7'
set['java']['install_flavor'] = 'oracle'
set['java']['oracle']['accept_oracle_download_terms'] = true
```

recipes/default.rb:

```
include_recipe 'java'
```

This will have the same effect as the role you’ve built, while simplifying things, and consolidating the settings you want. You might also include all of the package installations in your cookbook recipe as well, using the `package` resource.

-- 
Jeff Byrnes
@thejeffbyrnes
Lead DevOps Engineer
704.516.4628

On June 28, 2015 at 9:44:25 PM, Kurt Andrews ( "> ) wrote:

Tensibai,

That helped. I moved the roles directory up under my chef-repo, told chef_zero where to find it, and changed the add_recipe to add_role. Everything works now, and I can move on to the installation of the packages I'm really interested in.

On Sun, Jun 28, 2015 at 4:12 PM Tensibai Zhaoying < "> > wrote:


Le 28 juin 2015 21:18, Kurt Andrews < " target="_blank"> > a écrit :
>
> I'v only been using chef for a few hours, and the learning curve seemed really easy until... 
>
> I'm trying to right a recipe that installs several software packages on an Ubuntu 12.04 virtual machine.  The first thing it needs to do is install Oracle JDK 7.  I decided to try to use the java cookbook in the Chef Supermarket.  after looking at the documentation, I added a base role to my cookbook that looks like this (base.rb):

Unless you stated an error there,  you problem is here, a role is something aside the cookbook, not within. It's part of the runlist. I'm not comfortable to give links from phone, try a search on http://docs.chef.io for the node runlist, roles and cookbook and feel free to ping the list back with details of your cookbook and what you did ;)

>
> name "java"
> description "Install Oracle Java on Ubuntu"
> override_attributes(
>   "java" => {
>     "jdk_version" => '7'
>     "install_flavor" => "oracle"
>     "oracle" => {
>       "accept_oracle_download_terms" => true
>     }
>   }
> )
> run_list(
>   "recipe[java]"
> )
>
> I expected the run list to execute the java::default recipe when chef_zero ran mine.  That didn't happen.  I added the following line to my recipe, the only thing in my default.rb at the moment:
>
> include_recipe "java"
>
> That got me a little farther.  I'm now getting the following output when I vagrant up:
>
> ==> default:  27:  include_recipe "java::set_attributes_from_version"
> ==> default:  28:  include_recipe "java::#{node['java']['install_flavor']}"
> ==> default:  29:  
> ==> default: 
> ==> default: [2015-06-28T11:27:27-07:00] ERROR: Running exception handlers
> ==> default: [2015-06-28T11:27:27-07:00] ERROR: Exception handlers complete
> ==> default: [2015-06-28T11:27:27-07:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
> ==> default: [2015-06-28T11:27:27-07:00] ERROR: undefined method `[]' for nil:NilClass
> ==> default: [2015-06-28T11:27:28-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>
> chef-stacktrace.out points to line 21 of java::default.rb
>
> First and foremost, what am I missing?  Something isn't getting defined, but I can't tell what it is, or where to define it.
>
> The second question is what is the run_list for in a role, and when does it get processed? What kicks it off?
>
> Thanks in advance for straightening me out.
>
> Regards,
>
> Kurt
>




Archive powered by MHonArc 2.6.16.

§