简体   繁体   中英

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM