[chef] Re: Using ruby_block


Chronological Thread 
  • From: Daniel DeLeo < >
  • To:
  • Subject: [chef] Re: Using ruby_block
  • Date: Sat, 26 Jan 2013 11:42:28 -0800


On Saturday, January 26, 2013 at 3:56 AM, Sachin Sagar Rai wrote:

Ohai! chefs!

My Recipe has to import from S3, extract and seed the data from the mysqldump.

To do this, I want it using ruby and the aws-sdk gem.
AFAIK, the ruby code in the recipe file is evaluated at compil time and the ones that are inside `ruby_block` is evaluated at convergence time.
So if I do `require 'aws'`, it won't since its not installed. When I add it inside the ruby_block, it errors out.
So to fix it, I used the `chef_gem 'aws-sdk'`, but this will run at the compile time which is fine.
But to install it, it depends on packages like lib-xml2 to be installed too at the compile time.

You can either continue the arms race of moving resources to compile time, which means you probably need to install build-essentials, libxml2-dev, etc. at compile time, too, or you can split your recipe into smaller bits and put each piece at an appropriate place in the run_list, which might look like this:

1. build-essential
2. aws::install_gem (would install libxml2-dev or you could put that in a different recipe before this one if you want)
3. recipe that does things with aws gem be anywhere after this in your run_list

-- 
Daniel DeLeo




Archive powered by MHonArc 2.6.16.

§