a--m
a--m

Reputation: 4782

How to install a gem into rvm with puppet on a vagrant box?

I've setup a simple Vagrant box with puppet provisioner. With puppet I've installed rvm:

exec { 'install_rvm':
  command => "${as_vagrant} 'curl -L https://get.rvm.io | bash -s stable'",
  creates => "${home}/.rvm",
  require => Package['curl']
}

and ruby:

exec { 'install_ruby':
  command => "${as_vagrant} '${home}/.rvm/bin/rvm install 2.0.0 --latest-binary --autolibs=enabled && rvm --fuzzy alias create default 2.0.0'",
  creates => "${home}/.rvm/bin/ruby",
  require => Exec['install_rvm']
}

I'm trying to install a gem that would be available on the default ruby version of rvm (in this case 2.0.0)

If I try the puppet documented code it doen's work (I suppose it instals the gem on the system ruby):

package { 'sinatra':
    ensure   => 'installed',
    provider => 'gem',
}

Current workaround: If I execute a command as a vagrant user it works, but it doesn't look nice:

$as_vagrant   = 'sudo -u vagrant -H bash -l -c'

exec { "${as_vagrant} 'sudo -u vagrant -H bash -l -c gem install stasis'":
  require => Exec['install_ruby']
}

Any ideas?
Thank you.

Upvotes: 3

Views: 3120

Answers (1)

Marcos Brigante
Marcos Brigante

Reputation: 1000

You could use this rvm module from puppet forge. Check the Vagrant documentation about puppet to know how to use puppet modules with vagrant.

Upvotes: 2

Related Questions