I would like to provision a new Ubuntu 10.04 box with Ruby 1.9.2. I'm using Vagrant and Chef Solo to provision the box with everything else I need (e.g. Rails, Rake, MongoDB). The default Ruby version is 1.8.7.
Is there a way to install Ruby 1.9.2 as part of the Vagrant/Chef provisioning process?
I've read on the Chef website about using my own bootstrap template — possibly with knife — such as this one, but because I'm using Vagrant I'm not sure where to put this template — I don't have a chef-repo, a .chef directory or even any Chef stuff installed in /etc/chef.
First, a bit of context. Most Vagrant baseboxes install Ruby for use by Chef and Puppet, but the latest ones do this into /opt/ruby rather than using the system packages. They also add /opt/ruby/bin to the path, but at the end.
This VeeWee template shows how the 10.04 box is currently built: https://github.com/jedi4ever/veewee/blob/master/templates/ubuntu-10.04.3-server-i386/postinstall.sh
As for your question, their are several different contexts you might be trying to address, each with a different solution. Hopefully one of these will be what you're looking for.
Run Chef recipes with 1.9.2
You might be wanting to test running Chef recipes under 1.9.2 and you don't want 1.8.7 anywhere near your box. The best way of approaching this would be to create your own VeeWee template and build yourself a new basebox. You could modify the one linked above to compile 1.9.2 instead of 1.8.7 and follow the instructions on https://github.com/jedi4ever/veewee
Develop with Ruby 1.9.2
Probably more likely is that you want to hack on some Ruby code using 1.9.2. For this you just need to install Ruby and have the binaries on your path before the /opt/ruby entry. There are several ways of doing this:
All of these could be managed using a Chef recipe. I'd probably not go for the compile option, leaving either just a straight download and package resource or the following RVM cookbook might be handy http://community.opscode.com/cookbooks/rvm for RVM.
The *gem_binary* option on the package resource might also be useful here depending on how you want to ensure gems get installed for your new 1.9.2 Ruby (rather than the 1.8.7 in opt)
The goal of knife bootstrap
is to get Chef installed on the target system so it can run Chef Client. The Vagrant baseboxes tend to already have Chef installed so unless you're doing something specific and want to run multiple versions of Chef I'd avoid this route. The built in Chef provisioners like http://vagrantup.com/docs/provisioners/chef_solo.html are a better bet.
I know the question is quite old and already answered, but I hope this still may be interesting for someone stumbling upon this question.
I've built a Github repo which intends to provide several configurations for building and provisioning a Vagrant box without requiring to write a provisioning recipe from scratch.
For example, using the currently provided configuration, you can build and provision a box with:
Here is an introduction article on my blog.
Since this almost match the request, I felt it was worth adding this late answer :)
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