How to use gem_package


#1

Hi,

I am trying to convert bundle scripts to chef. I am not a strong ruby
developer.

I am confused on how to translate the below into a gem_package e.g.

gem_package “unicorn” do
action :install
end

There are the patterns I dont know how to replicate and translate into
gem_package

gem “therubyracer”, require: 'v8’
gem ‘opml_saw’, github: ‘feedbin/opml_saw’, ref:
‘61d8c2d’

Thanks


#2

On Thursday, September 12, 2013 at 4:08 AM, David Montgomery wrote:

Hi,

I am trying to convert bundle scripts to chef. I am not a strong ruby developer.

I am confused on how to translate the below into a gem_package e.g.

gem_package “unicorn” do
action :install
end

There are the patterns I dont know how to replicate and translate into gem_package

gem “therubyracer”, require: 'v8’
gem ‘opml_saw’, github: ‘feedbin/opml_saw’, ref: ‘61d8c2d’

Thanks
I’m not sure this is the best idea. The point of bundler is that with your application code plus the Gemfile.lock, you have an artifact from which you can reproduce an exact copy of your application and the code it depends on. If you just want to deploy a ruby application that’s developed with bundler using Chef, I’d recommend either using the git resource plus an execute resource to fetch your app code and run bundler, or use the deploy resource (which is basically the capistrano deployment strategy ported to Chef).

Using gem_package in a Chef recipe is a good choice for installing gems to a system or app-specific ruby installation when you need those gems available outside of your app. One obvious example here is to use gem_package to install bundler so you can use it to bundle install your app.

Git resource: http://docs.opscode.com/resource_git.html
Deploy resource: http://docs.opscode.com/resource_deploy.html

All resources in one big page: http://docs.opscode.com/chef/resources.html

HTH,


Daniel DeLeo