With 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 { 'ruby-1.9.3': default_use => true; 'ruby-2.0.0':; 'jruby':; }
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
rvm::system_rubies: '1.9': default_use: true '2.0': {} 'jruby-1.7': {} rvm::system_users: - vagrant
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 😉
http://mestachs.wordpress.com/2013/10/02/puppet-spare-3-minutes-per-provisionning-for-your-ruby-installation/
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
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)
old Puppet version?
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.
you will need puppet 3.0.0+
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 ?
Regards,
Mihai
what exact version of Puppet?
it was my fault, i was using puppet 2.7
thanks
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.
Regards,
Vineet