Libvirt provider

Adding Packer Qemu builder:
* Packer/answer_files/*_virtio: Install the virtio drivers from the ISO (NOT provided)
* windows_*.json needs some manual tweaks to match the virtio drivers ISO path

Adding Vagrant-libvirt provider:
* Uses the QEMU qcow2 images provided by packer to build the DetectionLab
* Vagrantfile needs manual tweaking to match libvirt's host configuration (backing store, network interfaces, etc)

README:
* Added separate README with instructions for libvirt
This commit is contained in:
Selora
2019-04-24 11:30:47 -04:00
committed by Selora
parent 4d13f53866
commit 2a6cb92f51
10 changed files with 865 additions and 9 deletions

98
Vagrant/Vagrantfile vendored
View File

@@ -1,7 +1,26 @@
libvirt_win10_box = "../Boxes/windows_10_libvirt.box"
libvirt_win2016_box = "../Boxes/windows_2016_libvirt.box"
Vagrant.configure("2") do |config|
config.vm.provider "libvirt" do |libvirt|
# This is required for Vagrant to properly configure the network interfaces.
# See libvirt's README section for more information
libvirt.management_network_name = "VagrantMgmt"
libvirt.management_network_address = "192.168.123.0/24"
libvirt.management_network_mode = "none"
libvirt.cpu_mode = "host-passthrough"
# Which storage pool path to use. Default to /var/lib/libvirt/images or ~/.local/share/libvirt/images depending on if you are running a system or user QEMU/KVM session.
#libvirt.storage_pool_path = '/media/storage_nvme/system_session_vm_pool'
libvirt.storage_pool_name = 'default'
end
config.vm.define "logger" do |cfg|
cfg.vm.box = "bento/ubuntu-18.04"
cfg.vm.box = "generic/ubuntu1604"
cfg.vm.hostname = "logger"
cfg.vm.provision :shell, path: "bootstrap.sh"
cfg.vm.network :private_network, ip: "192.168.38.105", gateway: "192.168.38.1", dns: "8.8.8.8"
@@ -24,6 +43,17 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end
cfg.vm.provider "libvirt" do |lv, override|
lv.graphics_type = "vnc"
lv.video_type = "vga"
lv.input :type => "tablet", :bus => "usb"
lv.video_vram = 32768
lv.memory = 4096
lv.cpus = 2
override.vm.synced_folder './', '/vagrant', type: 'rsync'
end
end
config.vm.define "dc" do |cfg|
@@ -35,9 +65,10 @@ Vagrant.configure("2") do |config|
cfg.winrm.basic_auth_only = true
cfg.winrm.timeout = 300
cfg.winrm.retry_limit = 20
cfg.vm.network :private_network, ip: "192.168.38.102", gateway: "192.168.38.1"
cfg.vm.network :private_network, ip: "192.168.38.102", gateway: "192.168.38.1", dns: "8.8.8.8"
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: false, args: "192.168.38.102"
# Added DNS here because libvirt fails to properly configure the windows client otherwise... :(
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: true, args: "-ip 192.168.38.102 -dns 8.8.8.8 -gateway 192.168.38.1"
cfg.vm.provision "shell", path: "scripts/provision.ps1", privileged: false
cfg.vm.provision "reload"
cfg.vm.provision "shell", path: "scripts/provision.ps1", privileged: false
@@ -77,6 +108,26 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end
cfg.vm.provider "libvirt" do |lv, override|
lv.graphics_type = "spice"
lv.video_type = "qxl"
lv.input :type => "tablet", :bus => "usb"
override.vm.box = libvirt_win2016_box
lv.video_vram = 32768
lv.memory = 3072
lv.cpus = 2
# This is NOT the right semantic for Vagrant synced folder. It's a dirty hack around :
# https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders/issues/11
# If dest is /vagrant, it'll upload in C:\vagrant\Vagrant....
# It's like 'cp /my/dir /my/dir2' vs 'cp /my/dir /my/dir2/'
#
# The Winrm synced folder plugin is also excruciatingly slow. Would gladly replace with something else
# that works with linux host and windows guest...
override.vm.synced_folder '.', '/', type: 'winrm'
end
end
config.vm.define "wef" do |cfg|
@@ -89,7 +140,7 @@ Vagrant.configure("2") do |config|
cfg.winrm.retry_limit = 20
cfg.vm.network :private_network, ip: "192.168.38.103", gateway: "192.168.38.1", dns: "192.168.38.102"
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: false, args: "-ip 192.168.38.103 -dns 192.168.38.102"
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: true, args: "-ip 192.168.38.103 -dns 8.8.8.8 -gateway 192.168.38.1"
cfg.vm.provision "shell", path: "scripts/provision.ps1", privileged: false
cfg.vm.provision "shell", inline: "cscript c:\\windows\\system32\\slmgr.vbs -rearm", privileged: false
cfg.vm.provision "reload"
@@ -129,6 +180,25 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end
cfg.vm.provider "libvirt" do |lv, override|
lv.graphics_type = "spice"
lv.video_type = "qxl"
lv.input :type => "tablet", :bus => "usb"
override.vm.box = libvirt_win2016_box
lv.video_vram = 32768
lv.memory = 2048
lv.cpus = 2
# This is NOT the right semantic for Vagrant synced folder. It's a dirty hack around :
# https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders/issues/11
# If dest is /vagrant, it'll upload in C:\vagrant\Vagrant....
# It's like 'cp /my/dir /my/dir2' vs 'cp /my/dir /my/dir2/'
#
# The Winrm synced folder plugin is also excruciatingly slow. Would gladly replace with something else
# that works with linux host and windows guest...
override.vm.synced_folder '.', '/', type: 'winrm'
end
end
config.vm.define "win10" do |cfg|
@@ -141,7 +211,7 @@ Vagrant.configure("2") do |config|
cfg.winrm.retry_limit = 20
cfg.vm.network :private_network, ip: "192.168.38.104", gateway: "192.168.38.1", dns: "192.168.38.102"
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: false, args: "-ip 192.168.38.104 -dns 192.168.38.102"
cfg.vm.provision "shell", path: "scripts/fix-second-network.ps1", privileged: true, args: "-ip 192.168.38.104 -dns 8.8.8.8 -gateway 192.168.38.1"
cfg.vm.provision "shell", path: "scripts/MakeWindows10GreatAgain.ps1", privileged: false
cfg.vm.provision "shell", path: "scripts/provision.ps1", privileged: false
cfg.vm.provision "shell", inline: "cscript c:\\windows\\system32\\slmgr.vbs -rearm", privileged: false
@@ -178,5 +248,23 @@ Vagrant.configure("2") do |config|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["setextradata", "global", "GUI/SuppressMessages", "all" ]
end
cfg.vm.provider "libvirt" do |lv, override|
lv.graphics_type = "spice"
lv.video_type = "qxl"
lv.input :type => "tablet", :bus => "usb"
override.vm.box = libvirt_win10_box
lv.video_vram = 32768
lv.memory = 2048
lv.cpus = 2
# This is NOT the right semantic for Vagrant synced folder. It's a dirty hack around :
# https://github.com/Cimpress-MCP/vagrant-winrm-syncedfolders/issues/11
# If dest is /vagrant, it'll upload in C:\vagrant\Vagrant....
# It's like 'cp /my/dir /my/dir2' vs 'cp /my/dir /my/dir2/'
#
# The Winrm synced folder plugin is also excruciatingly slow. Would gladly replace with something else
# that works with linux host and windows guest...
override.vm.synced_folder '.', '/', type: 'winrm'
end
end
end