Reputation: 30766
I can manually run bundle install
and get something sane back, but when I let Puppet provision a Vagrant box, this happens the second time (the first I get successful output).
[default] Running provisioner: Vagrant::Provisioners::Puppet...
[default] Running Puppet with /tmp/vagrant-puppet/manifests/default.pp...
stdin: is not a tty
/opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:900:in `report_activate_error': Could not find RubyGem puppet (>= 0) (Gem::LoadError)
from /opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:248:in `activate'
from /opt/vagrant_ruby/lib/ruby/site_ruby/1.8/rubygems.rb:1276:in `gem'
from /opt/vagrant_ruby/bin/puppet:18
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
I am not requesting the puppet gem anywhere, it's not in my Gemfile and my manifest does not require it either. Why is the puppet gem being looked for, and how do I get rid of this error?
Upvotes: 4
Views: 1870
Reputation: 112
Puppet is expected to be run by vagrant with the system ruby, but RVM may default to your chosen installed ruby. To work around this, I did this (a pretty ugly hack) while still having a default ruby when logging in normally:
In your vagrant file:
# setup working dir only to exploit in below
working_dir = '/home/vagrant/puppet'
config.vm.provision :shell, :inline => "mkdir -p #{working_dir}"
config.vm.provision "puppet" do |puppet|
# [ ... Your config ... ]
# before puppet is run, vagrand `cd`s into the working directory, failing to escape it.
puppet.working_directory = "#{working_dir}; rvm use system || true"
end
Due to an escaping bug/feature in the vagrant puppet provider (https://github.com/mitchellh/vagrant/blob/master/plugins/provisioners/puppet/provisioner/puppet.rb#L154) this causes vagrant to
Upvotes: 0
Reputation: 2088
I'm using https://github.com/blt04/puppet-rvm for provisioning my Vagrant box with RVM and I get the same problem. Unsetting "default_use => true" indeed fixes it. Unfortunately then you have to manually select your target Ruby once you ssh'd into the box.
Alternatively, you can add the puppet gem explicitly to the default Ruby in your manifest (not to any gemset, just to the Ruby itself). It still kept bugging me about some config file for hiera (??) missing, but it seemed to work anyway.
I'm wondering if RVM on Vagrant is even worth the hassle. The whole point about creating a Vagrant box is to have an isolated environment for a single project, so why would I need multiple Rubies/Gemsets then?
Upvotes: 3
Reputation: 46
Puppet is run by you VM on your VM. Make sure the gem is still installed for users vagrant and root. It could be a switch of your default ruby version too (system vs installed via rvm or rbenv ?).
Hope this helps.
Upvotes: 2