Installing RVM and multiple ruby versions with Puppet

rvm_logoWith the latest version of the Puppet RVM module it is even easier to install multiple versions of Ruby

# install rubies from binaries
Rvm_system_ruby {
  ensure     => present,
  build_opts => ['--binary'],

# ensure rvm doesn't timeout finding binary rubies
# the umask line is the default content when installing rvm if file does not exist
file { '/etc/rvmrc':
  content => 'umask u=rwx,g=rwx,o=rx
                     export rvm_max_time_flag=20',
  mode    => '0664',
  before  => Class['rvm'],

class { 'rvm': }
rvm::system_user { 'vagrant': }
rvm_system_ruby {
    default_use => true;

Hiera can also be used to define what rubies to install, making the Puppet code even less verbose

class { 'rvm': }
# rvm::system_user no longer needed
# rvm_system_ruby no longer needed

The equivalent hiera yaml configuration to the previous example

    default_use: true
  '2.0': {}
  'jruby-1.7': {}

  - vagrant

10 thoughts on “Installing RVM and multiple ruby versions with Puppet

  1. If you want to speed up the ruby version installation, I manage to spare a few minutes by using an exec to run a rvm mount command. Is this possible with the rvm puppet module ?

    Did you investigate if it’s possible to make a package (debian, yum) of rvm and their rubies (with fpm or omnibus) ?
    I trying to stop depending on the whole internet to provision a machine 😉

    • mount is not available in the module yet, it would be interesting to add, although you still need to put the tarballs somewhere. I use a shared folder in my host for vagrant boxes to avoid redownloading everything.

      About packaging I try to avoid repackaging if the project itself doesn’t support it, because in next versions it will break for sure

  2. Hello thanks for the post, I put exactly the same code that you posted.. on my puppet recipe, the only change that I did.. was set the default_use => true to jruby…….. but when I run the provision, I got this error: Could not autoload rvm_system_ruby:

    Could not autoload /tmp/vagrant-puppet-1/modules-0/rvm/lib/puppet/provider/rvm_system_ruby/rvm_system_ruby.rb: undefined method `has_command’ for Puppet::Type::Rvm_system_ruby::ProviderRvm:Class at

    could you help me, I am using the precise64 box, (ubuntu 12.04 64bits)

      • I’m using puppet v 2.7.19, I don’t know why this problem happen, y went to the path, until rvm_system_ruby.rb and the method ‘has_command’ exists, and if I go to the init.pp (rvm module), on line 23 : create_resources(‘rvm_system_ruby’, $system_rubies, {‘ensure’ => present}), here is where the problem apparently ocurr,

        (sorry for my bad english), but if you know something about, I will really appreciate.

  3. Hi,

    i’m also getting this error:

    Could not autoload rvm_system_ruby: Could not autoload /tmp/vagrant-puppet-1/modules-0/rvm/lib/puppet/provider/rvm_system_ruby/rvm_system_ruby.rb: undefined method `has_command’ for Puppet::Type::Rvm_system_ruby::ProviderRvm:Class at /tmp/vagrant-puppet-1/modules-0/rvm/manifests/init.pp:25 on node web

    using Puppet 3.

    Can you help me please ?


  4. Hi,

    I’ve been able to install the ruby version I would want but still the system ruby is in use. How do we run “rvm use” with puppet? As it does not accept full path for rvm because ‘rvm is not a function’ and Puppet’s exec forces all commands to be fully qualified.


Leave a Reply to Vineet Madan Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s