Vagrant with libvirt on Ubuntu

Add Vagrant GPG key and repo:

wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
Update and install:
sudo apt update
sudo apt install -y vagrant libvirt-daemon-system qemu-kvm libvirt-clients bridge-utils ebtables dnsmasq-base
Start libvirt:
sudo systemctl enable --now libvirtd
Add current user to the groups:
sudo adduser "$(id -un)" libvirt
sudo adduser "$(id -un)" kvm
Reboot
sudo reboot
Install Vagrant dev dependencies:
sudo apt install -y gcc ruby-libvirt make libxslt1-dev libxml2-dev libvirt-dev zlib1g-dev ruby-dev
Install libvirt plugin for Vagrant:
vagrant plugin install vagrant-libvirt
Create a dir, switch to it:
mkdir lfcs
cd lfcs
and create Vagrantfile:
Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-24.04"
  config.vm.provision "ansible_local", playbook: "ubuntu.yml"
  config.vm.provider "libvirt" do |v|
    v.memory = 2048
    v.cpus = 2
  end

  # specific for ubuntu1
  config.vm.define "ubuntu1" do |ubuntu1|
    ubuntu1.vm.hostname = "ubuntu1"
    ubuntu1.vm.network "private_network", ip: "192.168.121.101"
  end

  # specific for ubuntu2
  config.vm.define "ubuntu2" do |ubuntu2|
    ubuntu2.vm.hostname = "ubuntu2"
    ubuntu1.vm.network "private_network", ip: "192.168.121.102"
  end
end
Optional Ansible playbook file - ubuntu.yaml:
# Place in directory you run Vagrant from, alongside the Vagrantfile
- name: Configure Ubuntu
  hosts: all
  become: true
  gather_facts: false
  tasks:
    - name: Update Package Cache and Upgrade Existing Packages
      apt:
        update_cache: true
        upgrade: true
    - name: Ensure SSH Allows Password Authentication
      lineinfile:
        path: /etc/ssh/sshd_config
        line: PasswordAuthentication yes
        regexp: '^PasswordAuthentication .*$'
      notify: RestartSSH
  handlers:
    - name: RestartSSH
      service:
        name: ssh
        state: restarted
These are adapted files from LFCS repo

Spin un 2 Ubuntu machines:
vagrant up
To SSH to them:
vagrant ssh ubuntu1
vagrant ssh ubuntu2
If you want to login via IP - username is vagrant and password is vagrant:
ssh vagrant@192.168.121.101 # ubuntu1
ssh vagrant@192.168.121.102 # ubuntu2