domingo, 31 de enero de 2016

Vagrant + libvirt plugin in OpenSuSE Leap 42.1

First bit, install from https://software.opensuse.org/package/vagrant

The first command (vagrant reload) that I needed, I find the error:

WARN: Unresolved specs during Gem::Specification.reset:
      childprocess (>= 0)
      ffi (>= 0.5.0)
      net-ssh (>= 2.6.5)
      rest-client (>= 0)


sudo gem install ffi -> mkmf.rb can't find header files for ruby at /usr/lib64/ruby/include/ruby.h

Fuck my life...

Install ruby2.1-devel using YaST

sudo gem install ffi -> SUCCESS.
sudo gem install childprocess -> SUCCESS
sudo gem install rest-client -> Fuck my life again

nonsense
nonsense
compiling unf.cc
make: g++: Command not found
Makefile:204: recipe for target 'unf.o' failed
make: *** [unf.o] Error 127

make failed, exit code 2
nonsense
nonnsense

Install gcc-c++ using YaST

sudo gem install rest-client -> SUCCESS
sudo gem install net-ssh -> SUCCESS!!

Let's try again with "vagrant reload"

nonsense
nonsense
Vagrant experienced a version conflict with some installed plugins!
This usually happens if you recently upgraded Vagrant. As part of the
upgrade process, some existing plugins are no longer compatible with
this version of Vagrant. The recommended way to fix this is to remove
your existing plugins and reinstall them one-by-one. To remove all
plugins:

    rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems
nonsense
nonsense

This might be related with an old installation I had few minutes ago, if it happens...
rm -r ~/.vagrant.d/plugins.json ~/.vagrant.d/gems

And try again with "vagrant reload"

nonsense
nonsense
The provider 'libvirt' could not be found, but was requested to
back the machine 'all_apps'. Please use a provider that exists.


This is actually good, you passed stage 1, let's try with stage 2, installing the plugin:

sudo vagrant plugin install libvirt -> fuck my life, and do it hard.

The plugin(s) can't be installed due to the version conflicts below.
This means that the plugins depend on a library version that conflicts
with other plugins or Vagrant itself, creating an impossible situation
where Vagrant wouldn't be able to load the plugins.

You can fix the issue by either removing a conflicting plugin or
by contacting a plugin author to see if they can address the conflict.

Vagrant could not find compatible versions for gem "ffi":
  In Gemfile:
    vagrant (= 1.7.4) ruby depends on
      listen (>= 0) ruby depends on
        rb-inotify (>= 0.9) ruby depends on
          ffi (>= 0.5.0) ruby

    vagrant (= 1.7.4) ruby depends on
      childprocess (>= 0) ruby depends on
        ffi (>= 1.0.11, ~> 1.0) ruby

    libvirt (>= 0) ruby depends on
      ffi (~> 0.6.3) ruby


Apparently, we're requiring ffi >= 0.5.0, and ffi >=1.0.11, and ffi = 0.6.3. Obviously it's complicated to fulfil all requirements at the same time. IMHO, libvirt version is the guilty.

From here, I had to read a bit more about the same problem:
https://github.com/mitchellh/vagrant/issues/3897

So we try:
vagrant plugin install vagrant-libvirt

Red is getting redder


Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually                                             
caused by misconfigured plugin installations or transient network                                                 
issues. The error from Bundler is:                                                                                

An error occurred while installing nokogiri (1.6.7.2), and Bundler cannot continue.                               
Make sure that `gem install nokogiri -v '1.6.7.2'` succeeds before bundling.                                      

Warning: this Gemfile contains multiple primary sources. Using `source` more than once without a block is a security risk, and may result in installing unexpected gems. To resolve this warning, use a block to indicate which gems should come from the secondary source. To upgrade this warning to an error, run `bundle config disable_multisource true`.Gem::Ext::BuildError: ERROR: Failed to build gem native extension.                                           

    /usr/bin/ruby.ruby2.1 extconf.rb                                                                              
checking if the C compiler accepts ... yes                                                                        
Building nokogiri using packaged libraries.                                                                       
Using mini_portile version 2.0.0                                                                                  
Static linking is disabled.                                                                                       
checking for gzdopen() in -lz... no                                                                               
zlib is missing; necessary for building libxml2                                                                   
*** extconf.rb failed ***                                                                                         
Could not create Makefile due to some reason, probably lack of necessary                                          
libraries and/or headers.  Check the mkmf.log file for more details.  You may                                     
need configuration options.                                                                                       

Provided configuration options:                                                                                   
        --curdir
        --ruby=/usr/bin/ruby.ruby2.1
        --help
        --clean
        --use-system-libraries
        --enable-static
        --disable-static
        --with-zlib-dir
        --without-zlib-dir
        --with-zlib-include
        --without-zlib-include=${zlib-dir}/include
        --with-zlib-lib
        --without-zlib-lib=${zlib-dir}/lib64
        --enable-cross-build
        --disable-cross-build

extconf failed, exit code 1

Gem files will remain installed in /root/.vagrant.d/gems/gems/nokogiri-1.6.7.2 for inspection.
Results logged to /root/.vagrant.d/gems/extensions/x86_64-linux/2.1.0/nokogiri-1.6.7.2/gem_make.out


Within all this nonsense you can see "zlib is missing; necessary for building libxml2
"
Use YaST once again... zlib-devel

Now again.. 
sudo gem install nokogiri -v '1.6.7.2' -> SUCCESS

Finally...
sudo vagrant plugin install vagrant-libvirt -> RED AGAIN

Nonsense
Make sure that `gem install ruby-libvirt -v '0.6.0'` succeeds before bundling.
Nonsense
extconf.rb:73:in `<main>': libvirt library not found in default locations (RuntimeError)
Nonsense


Maybe... it'd be a good idea to install libvirt and libvirt-devel in my system using YaST again...

vagrant plugin install vagrant-libvirt -> Installed the plugin 'vagrant-libvirt (0.0.32)'! (Fuck YEAH!)

Summary:
Install with zypper, YaST or software.opensuse.org: vagrant ruby2.1-devel gcc-c++ zlib-devel and all its dependencies.
Install following gems with "sudo gem install" childprocess, ffi, net-ssh and rest-client
Install the right plugin, without sudo, "vagrant plugin install vagrant-libvirt"