I extensively use Vagrant along with the vagrant-libvirt plugin on my Arch Linux hosts to quickly set up development and lab environments. The plugin is mature and generally feature-complete; however, the latest release was published on June 24, 2023. Since then, multiple commits have been made to the main branch of the project repository.

I use the following process rather than the standard installation sourced from RubyGems .

Prerequisites

Verify these Arch packages are installed:

pacman -Q git vagrant dnsmasq libvirt qemu-base ruby pkgconf gcc make

Steps

  1. Open your favorite terminal emulator.

  2. Uninstall the existing vagrant-libvirt plugin (if required).

vagrant plugin uninstall vagrant-libvirt
  1. (Optional) Delete the gems directory in the Vagrant user data location.
rm -rf $HOME/.vagrant.d/gems
  1. Clone the vagrant-libvirt repo from GitHub.
git clone https://github.com/vagrant-libvirt/vagrant-libvirt.git
  1. Change to the vagrant-libvirt directory.
cd vagrant-libvirt
  1. Edit the vagrant-libvirt.gemspec file.
vim vagrant-libvirt.gemspec
  1. Specify a version constraint for the fog-json dependency.
16
17
18
19
20
21
22
23
24
25
26
27
28
   s.files         = Dir.glob("{lib,locales}/**/*") + %w(LICENSE README.md)
   s.executables   = Dir.glob("bin/*.*").map{ |f| File.basename(f) }
   s.test_files    = Dir.glob("{test,spec,features}/**/*.*")
   s.name          = 'vagrant-libvirt'
   s.require_paths = ['lib']
   s.version       = VagrantPlugins::ProviderLibvirt.get_version

+  s.add_runtime_dependency 'fog-json', '< 1.4.0'
   s.add_runtime_dependency 'fog-libvirt', '>= 0.6.0'
   s.add_runtime_dependency 'fog-core', '~> 2'
   s.add_runtime_dependency 'rexml'
   s.add_runtime_dependency 'xml-simple'
   s.add_runtime_dependency 'diffy'
  1. Edit the driver.rb file.
vim lib/vagrant-libvirt/driver.rb
  1. Remove the ip_command variable and the libvirt_ip_command key that references it.
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
        # Get config options for Libvirt provider.
        config = @machine.provider_config
        uri = config.uri

-       # Setup command for retrieving IP address for newly created machine
-       # with some MAC address. Get it from dnsmasq leases table
-       ip_command = %q( awk "/$mac/ {print \$1}" /proc/net/arp )
-
        conn_attr = {
          provider: 'libvirt',
          libvirt_uri: uri,
-         libvirt_ip_command: ip_command,
        }
        conn_attr[:libvirt_username] = config.username if config.username
        conn_attr[:libvirt_password] = config.password if config.password
  1. Build the vagrant-libvirt plugin.
gem build -o vagrant-libvirt.gem
  1. Install the vagrant-libvirt plugin.
VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT=1 vagrant plugin install ./vagrant-libvirt.gem