Skip to content

Instantly share code, notes, and snippets.

@smijar
Last active March 11, 2022 23:57
Show Gist options
  • Save smijar/8747d1c77a39b504646c2d685d0d1441 to your computer and use it in GitHub Desktop.
Save smijar/8747d1c77a39b504646c2d685d0d1441 to your computer and use it in GitHub Desktop.
# ref
read: https://github.com/vagrant-libvirt/vagrant-libvirt
install: https://fedoramagazine.org/vagrant-qemukvm-fedora-devops-sysadmin/
nested: https://adrianriobo.github.io/virtualization/testing/environment/2020/10/13/vagrant-nested-virtualization.html
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# sudo virsh net-list --all
# sudo virsh net-dumpxml $NETWORK_NAME
# sudo virsh list --all
vm_script = <<-SCRIPT
#!/bin/bash
set -euxo pipefail
echo hello, world!
SCRIPT
Vagrant.configure("2") do |config|
#inline: "echo Hello, World"
config.vm.box = "fedora/34-cloud-base"
# config.vm.synced_folder "~/dev", "/vagrant/dev", type: "rsync",
# rsync__exclude: ".git/"
# config.vm.synced_folder "./", "/vagrant", type: "9p", disabled: false, accessmode: "squash", owner: "1000"
config.vm.synced_folder "~/dev", "/home/vagrant/dev", type: "9p", disabled: false, accessmode: "squash", owner: "1000"
config.vm.provider :libvirt do |libvirt|
# Enable KVM nested virtualization
libvirt.nested = true
#host-model is deprecated at rhel 8 use pass-through instead
libvirt.cpu_mode = "host-passthrough"
# Increase memory allocation for CRC requirements
libvirt.cpus = "4"
libvirt.memory = 10238
libvirt.machine_virtual_size = 100
end
config.vm.provision "shell" do |s|
#s.inline = "echo hello"
s.inline = vm_script
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment