Libvirt machine creation in a loop with additional disks

Hello,

I’m trying to create 4 machines in a loop with an additional disk. Here’s what I’ve tried:

Vagrant.configure("2") do |config|                                                                                                  
  config.vm.box = "centos-8-stream"                                                                                                 
                                                                                                                                    
  config.vm.network :public_network,                                                                                                
    :dev => "virbr1",                                                                                                               
    :libvirt_network_name => "private",                                                                                             
    :type => "bridge"                                                                                                               
                                                                                                                                    
  config.vm.provider :libvirt do |libvirt|                                                                                          
    libvirt.cpus = 4                                                                                                                
    libvirt.driver = "kvm"                                                                                                          
    libvirt.graphics_type = "spice"                                                                                                 
    libvirt.id_ssh_key_file = "$HOME/.ssh/id_ed25519"                                                                               
    libvirt.keymap = "es"                                                                                                           
    libvirt.machine_virtual_size = 50                                                                                               
    libvirt.memory = 4096                                                                                                           
    libvirt.storage_pool_name = "default"                                                                                           
    libvirt.uri = "qemu:///system"                                                                                                  
  end                                                                                                                               
                                                                                                                                    
  (0..3).each do |i|                                                                                                                
    config.vm.define "minio#{i}" do |node|                                                                                          
      node.vm.hostname = "minio#{i}.virt.g02.org"                                                                                   
                                                                                                                                    
      node.vm.provider :libvirt do |libvirt|                                                                                        
        libvirt.storage :file, :size => '100G', :path => "minio#{i}-vdb.img"                                                        
      end                                                                                                                           
    end                                                                                                                             
  end                                                                                                                               
end                                                                                                                                 

It doesn’t work. It fails like this:

[renich@introdesk centos8]$ vagrant up
Bringing machine 'minio0' up with 'libvirt' provider...
Bringing machine 'minio1' up with 'libvirt' provider...
Bringing machine 'minio2' up with 'libvirt' provider...
Bringing machine 'minio3' up with 'libvirt' provider...
==> minio1: Created volume larger than box defaults, will require manual resizing of
==> minio1: filesystems to utilize.
==> minio1: Creating image (snapshot of base box volume).
==> minio0: Created volume larger than box defaults, will require manual resizing of
==> minio0: filesystems to utilize.
==> minio3: Created volume larger than box defaults, will require manual resizing of
==> minio3: filesystems to utilize.
==> minio2: Created volume larger than box defaults, will require manual resizing of
==> minio2: filesystems to utilize.
==> minio0: Creating image (snapshot of base box volume).
==> minio2: Creating image (snapshot of base box volume).
==> minio3: Creating image (snapshot of base box volume).
==> minio1: An error occurred. The error will be shown after all tasks complete.
==> minio2: An error occurred. The error will be shown after all tasks complete.
==> minio3: An error occurred. The error will be shown after all tasks complete.
==> minio0: An error occurred. The error will be shown after all tasks complete.
An error occurred while executing multiple actions in parallel.
Any errors that occurred are shown below.

An unexpected error occurred when executing the action on the
'minio0' machine. Please report this as a bug:

undefined method `+' for nil:NilClass

/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:168:in `block in call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `each'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain_volume.rb:89:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_box_image.rb:124:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'

An unexpected error occurred when executing the action on the
'minio1' machine. Please report this as a bug:

undefined method `+' for nil:NilClass

/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:168:in `block in call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `each'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain_volume.rb:89:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_box_image.rb:124:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'

An unexpected error occurred when executing the action on the
'minio2' machine. Please report this as a bug:

undefined method `+' for nil:NilClass

/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:168:in `block in call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `each'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain_volume.rb:89:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_box_image.rb:124:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'

An unexpected error occurred when executing the action on the
'minio3' machine. Please report this as a bug:

undefined method `+' for nil:NilClass

/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:168:in `block in call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `each'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain.rb:159:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/create_domain_volume.rb:89:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_box_image.rb:124:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/handle_storage_pool.rb:57:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-libvirt-0.1.2/lib/vagrant-libvirt/action/set_name_of_domain.rb:32:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:127:in `block in finalize_action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/call.rb:53:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/box_check_outdated.rb:36:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/warden.rb:48:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/builder.rb:149:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `block in run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/util/busy.rb:19:in `busy'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/action/runner.rb:89:in `run'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:240:in `action_raw'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:212:in `block in action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/environment.rb:613:in `lock'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `call'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/machine.rb:198:in `action'
/usr/share/vagrant/gems/gems/vagrant-2.2.9/lib/vagrant/batch_action.rb:86:in `block (2 levels) in run'

As it turns out, Fedora 34 seems to ship vagrant-libvirt 0.1.2. This was the cause. I removed it and re-installed the plugin using: vagrant plugin install vagrant-libvirt. It works fine now.

I have another problem, though. I cannot use vagrant provision due to some odd bug; documented in vagrant-libvirt’s github README. FYI.