Controlling Vagrant plugin dependencies via Ansible

I have an Ansible playbook that installs Vagrant, and then instructs Vagrant to install a specific plugin. Vagrant has trouble installing a gem it needs, and says:

An error occurred while installing nokogiri (1.6.6.2), and Bundler cannot continue.
Make sure that `sudo gem install nokogiri -v '1.6.6.2'` succeeds before bundling.
stdout: Installing the 'vagrant-aws --version '0.5.0'' plugin. This can take a few minutes...

While I have trouble installing Nokogiri using the command:

$ sudo gem install nokogiri -v '1.6.6.2'

as vagrant does it, I have found that I can install Nokogiri manually, using this command:

$ sudo gem install nokogiri -v 1.6.6.2 -- --use-system-libraries --with-xml2-include=/usr/include/libxml2

Even after I installed the gem manually, vagrant still fails if I manually tell it to install the plugin.

Is there a way to get better control of these dependencies so that vagrant won't fail and my playbook will complete?

Upvotes: 3

Views: 1297

Answers (2)

mihow
mihow

Reputation: 424

I believe it's an issue with using sudo to install the ruby gem.

I solved this issue by installing Ruby Version Manager, which installs and manages gems in your home directory.

After installing RVM I could install nokogiri without sudo, but vagrant-aws still failed to install until I re-installed vagrant. If you are building a fresh environment with Ansible then you can probably just install RVM before you install vagrant the first time (or any other ruby stuff). There are other ways to fix your gem permissions as well.

Here are the steps I took:

Install Ruby Version Manager (https://rvm.io/rvm/install)

curl -sSL https://get.rvm.io | bash -s stable --ruby

Install nokogiri without sudo

gem install nokogiri

Re-install vagrant (http://www.vagrantup.com/downloads)

Upvotes: 0

It turns out I was missing some key dependencies: build-essential, libxslt1-dev, libxml2-dev, and zlib1g-dev. I found this comment here: https://github.com/mitchellh/vagrant-aws/issues/163#issuecomment-27603855 very helpful.

Upvotes: 1

Related Questions