Is there an up-to-date cookbook for ruby? I wasn't able to find one on the opscode cookbook site. i.e ruby 1.9.3 or 1.9.2p280.
I just finished updating Carlo Zottman's ruby 1.9.x cookbook (noticed this question while having lunch, prior to writing a pull request, lol...)
The only dependencies are the standard build-essential and apt cookbooks from the opscode cookbook site.
As for the discussion about when a cookbook such as this one might be needed, I'm using it to upgrade from ruby 1.8 to ruby 1.9 on my 12.04.01 vagrant boxes before using the rbenv cookbook (and various others).
I realize that I ought to be able to use the rbenv cookbook to install 1.9.3, but after futzing with that unsuccessfully for a couple of hours, I realized that I was happier with the source installation anyway, as it makes my whole recipe stack less brittle. And a shell script to rbenv install 1.9.3 as the vagrant user was trivial to write.
I found an alternative approach that has even fewer dependencies (yes!) I'm using Fletcher Nichol's cookbooks:
Strictly speaking, of course, you could just use ruby_build to install your preferred 1.9 and stop, but I want rbenv as well.
I've included some snippets from my setup (there's more to the Berksfile and Vagrantfile, of course, but these are the relevant bits.) The only truly tricky part is that the local name of the chef-rbenv
cookbook has to be rbenv
if you want to use any of the off-the-shelf recipes that include other off-the-shelf recipes from the cookbook, as it refers to itself as rbenv. Berkshelf made that trivial.
Berksfile:
group :ruby do
cookbook 'ruby_build'
cookbook 'rbenv', git: 'https://github.com/fnichol/chef-rbenv'
end
Vagrantfile:
config.vm.provision :chef_solo do |chef|
chef.cookbooks_path = 'chef/cookbooks'
chef.roles_path = 'chef/roles'
chef.json = {
'rbenv' => {
'global' => '1.9.3-p194',
'rubies' => [ '1.9.3-p194' ],
'gems' => {
'1.9.3-p194' => [
{ 'name' => 'bundler' }
]
}
}
}
chef.add_role 'ruby'
end
chef/roles/ruby.json:
{
"name": "ruby",
"description": "Install ruby and rbenv",
"chef_type": "role",
"json_class": "Chef::Role",
"run_list": [
"recipe[ruby_build]",
"recipe[rbenv::system]"
]
}
A final comment is that once I figured the solution out, I realized that Victor's answer is likely the chef server version of the same thing. I have only used chef-solo so far, so I am not sure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With