[chef] Re: mysql-0.23 cookbook fails on Lucid


Chronological Thread 
  • From: Joshua Timberman < >
  • To:
  • Subject: [chef] Re: mysql-0.23 cookbook fails on Lucid
  • Date: Thu, 15 Jul 2010 09:58:59 -0600

Hello!

On Jul 15, 2010, at 3:34 AM, Dmitry V'yal wrote:

> I have a node with a runlist:
> 
>  "run_list": [
>    "recipe[apt::default]",
>    "recipe[nginx::passenger]",
>    "recipe[mysql::server]",
>    "recipe[php-fpm::default]",
>    "recipe[monit::default]",
>    "recipe[bodhysite::default]",
>    "recipe[mail-system::vdomains]"
>  ],

Just to note, you don't need to specify default, it is implied if a recipe 
isn't specified for the cookbook.

E.g., "recipe[apt]" is the same as "recipe[apt::default]".

That said...

> nginx::passenger starts with include_recipe "build-essential".
> 
> The chef run fails saying this: http://pastebin.com/H7nFSqdy
> Looks like mysql::client fails while building mysql gem because mkfs from 
> ruby-dev is missing. So I added
> 
> r1 = package "ruby1.8-dev"
> r1.run_action(:install)
> ...
> Necessary headers are there, the root of problem is what gcc isn't 
> installed. But build-essential included as part of nginx::passenger earlier 
> than mysql. I even tried to add it into run_list as a separate recipe right 
> after apt::default, it didn't helped.

Recall that the Chef client run processes recipes in two phases[0] - the 
compile phase and the execution phase. During the compile phase your Ruby 
code is processed:

r1 = package "ruby1.8-dev"
r1.run_action(:install)

So this gets evaluated and the resource is created and the package installed. 
The mysql cookbook uses this 'trick' to ensure the mysql gem can be installed 
and later used in the mysql cookbook's library in the same Chef client run.

The build-essential and ruby cookbooks do not do this (the Opscode Ruby 
cookbook installs the ruby dev package, so you can use that). They create the 
package resources during the compile phase as normal but Chef doesn't 
actually run the package installation until the execution phase. You should 
modify your local copy of the build-essential recipe to have the following 
block for the package installation:

  %w{build-essential binutils-doc}.each do |pkg|
    p = package pkg do
      action :nothing
    end
    p.run_action(:install)
  end

And the ruby recipe to have the following:

extra_packages.each do |pkg|
  p = package pkg do
    action :nothing
  end
  p.run_action(:install)
end

Upload the cookbooks to the Chef Server and rerun Chef on the node in 
question.

Since we (Opscode) first distribute Chef as RubyGems, the recipes are a bit 
narrow-minded in assuming that by the time Chef runs for the first time the C 
compiler and Ruby dev packages are available, because that is required to 
build Gems (like json) with native extensions to get Chef installed in the 
first place.

It sounds like you have installed Chef from Debian/Ubuntu packages, which is 
good, but it does mean this adjustment in your local recipe is necessary.

That said, we'll look at how to make these cookbooks better, and the mysql 
cookbook's readme will be updated to reflect this "requirement".

[0]: Anatomy of a chef run: 
http://wiki.opscode.com/display/chef/Anatomy+of+a+Chef+Run

-- 
Opscode, Inc
Joshua Timberman, Senior Solutions Engineer
C: 720.334.RUBY E: 





Archive powered by MHonArc 2.6.16.

§