読者です 読者をやめる 読者になる 読者になる

vagrant-libvirt 入れた

前提

  • debian jessie
  • QEMU emulatar 2.1.2
  • 既にKVMホストが色々動いている状態
  • 他にはdockerも動いているけど今回初めてvagrant入れた

導入

vagrant入れる

公式サイトからdeb取ってきただけ。

# wget https://dl.bintray.com/mitchellh/vagrant/vagrant_1.7.2_x86_64.deb
# dpkg -i vagrant_1.7.2_x86_64.deb

devパッケージ入れる

# apt-get install ruby-dev libvirt-dev

rubylibvirt扱えるgem入れる

# gem install ruby-libvirt

vagrant-libvirt 入れたい

入れたかったけど転けた。

# vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...                                                                                                                          [370/10561]
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 ruby-libvirt (0.5.2), and Bundler cannot continue.
Make sure that `gem install ruby-libvirt -v '0.5.2'` succeeds before bundling.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /opt/vagrant/embedded/bin/ruby extconf.rb
*** 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:
        --with-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=/opt/vagrant/embedded/bin/ruby
        --with-libvirt-include
        --without-libvirt-include
        --with-libvirt-lib
        --without-libvirt-lib
        --with-libvirt-config
        --without-libvirt-config
        --with-pkg-config
        --without-pkg-config
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:434:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:519:in `try_link0'
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:534:in `try_link'
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:620:in `block in try_ldflags'
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:613:in `with_ldflags'
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:619:in `try_ldflags'
        from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:1725:in `pkg_config'
        from extconf.rb:72:in `<main>'


Gem files will remain installed in /home/whywaita/.vagrant.d/gems/gems/ruby-libvirt-0.5.2 for inspection.
Results logged to /home/whywaita/.vagrant.d/gems/gems/ruby-libvirt-0.5.2/ext/libvirt/gem_make.out

GNU ldとGNU goldの違いから起因するエラーなのでシンボリックリンク張る

# ln -fs /usr/bin/ld.gold /usr/bin/ld

vagrant-libvirt 入れる

whywaita@misora:~$ vagrant plugin install vagrant-libvirt
Installing the 'vagrant-libvirt' plugin. This can take a few minutes...
Installed the plugin 'vagrant-libvirt (0.0.30)'!

めでたしめでたし。