How to use this box with Vagrant:
Vagrant.configure("2") do |config|
config.vm.box = "cloud-image/ubuntu-22.04"
config.vm.box_version = "20240514.0.0"
end
vagrant init cloud-image/ubuntu-22.04 \
--box-version 20240514.0.0
vagrant up
This version was created about 2 months ago.
This is a Vagrant Box derived from the official Cloud Image without modification except for the Vagrant user injected using cloud-init configuration file.
Install libvirt provider using the standard Vagrant plugin installation commnd.
vagrant plugin install vagrant-libvirt
Create a minimal Vagrant file as follow:
Vagrant.configure("2") do |config|
config.vagrant.plugins = "vagrant-libvirt"
config.vm.box = "cloud-image/ubuntu-22.04"
config.vm.synced_folder ".", "/vagrant", disabled: true
end
Here a more exaustive example:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vagrant.plugins = "vagrant-libvirt"
config.vm.box = "cloud-image/ubuntu-22.04"
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :libvirt do |libvirt|
libvirt.driver = "kvm"
libvirt.uri = 'qemu:///system'
#libvirt.socket = '/var/run/libvirt/libvirt-sock'
#libvirt.host = 'localhost'
#libvirt.username = ''
#libvirt.password = ''
#libvirt.id_ssh_key_file = "$HOME/.ssh/id_rsa"
end
config.vm.define :node do |libvirt|
#libvirt.vm.network :forwarded_port, guest: 80, host: 4567
#libvirt.vm.network :public_network, :dev => 'br0', :mode => 'bridge', :type => 'bridge'
#libvirt.vm.network :public_network, :dev => 'br0', :mode => 'bridge', :type => 'bridge', :auto_config => false
libvirt.vm.provider :libvirt do |domain|
domain.memory = "1024"
domain.cpus = "1"
#domain.nested = true
#domain.cpu_mode = 'host-passthrough'
#domain.boot 'network'
#domain.boot 'hd'
#domain.storage :file, :size => '5G', :type => 'raw', :allow_existing => true
#domain.storage :file, :device => 'cdrom', :path => '/mnt/linux.iso'
#domain.graphics_type = 'none'
#domain.graphics_port = 5901
#domain.graphics_ip = '0.0.0.0'
end
#libvirt.vm.provision :shell, path: 'bootstrap.sh'
end
end