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:
98
Vagrant/Vagrantfile
vendored
98
Vagrant/Vagrantfile
vendored
@@ -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
|
||||
|
||||
@@ -57,6 +57,11 @@ test_prerequisites() {
|
||||
}
|
||||
|
||||
fix_eth1_static_ip() {
|
||||
USING_KVM=$(sudo lsmod | grep kvm)
|
||||
if [ ! -z "$USING_KVM" ]; then
|
||||
echo "[*] Using KVM, no need to fix DHCP for eth1 iface"
|
||||
return 0
|
||||
fi
|
||||
# There's a fun issue where dhclient keeps messing with eth1 despite the fact
|
||||
# that eth1 has a static IP set. We workaround this by setting a static DHCP lease.
|
||||
echo -e 'interface "eth1" {
|
||||
|
||||
@@ -1,10 +1,32 @@
|
||||
# Source: https://github.com/StefanScherer/adfs2
|
||||
param ([String] $ip, [String] $dns)
|
||||
param ([String] $ip, [String] $dns, [String] $gateway)
|
||||
|
||||
if (! (Test-Path 'C:\Program Files\VMware\VMware Tools')) {
|
||||
if ( (Get-NetAdapter | Select-Object -First 1 | Select-Object -ExpandProperty InterfaceDescription).Contains('Red Hat VirtIO')) {
|
||||
Write-Host "Setting Network Configuration for LibVirt interface"
|
||||
$subnet = $ip -replace "\.\d+$", ""
|
||||
$name = (Get-NetIPAddress -AddressFamily IPv4 `
|
||||
| Where-Object -FilterScript { ($_.IPAddress).StartsWith("$subnet") } `
|
||||
).InterfaceAlias
|
||||
if ($name) {
|
||||
Write-Host "Set IP address to $ip of interface $name"
|
||||
& netsh.exe int ip set address "$name" static $ip 255.255.255.0 "$gateway"
|
||||
if ($dns) {
|
||||
Write-Host "Set DNS server address to $dns of interface $name"
|
||||
& netsh.exe interface ipv4 add dnsserver "$name" address=$dns index=1
|
||||
}
|
||||
} else {
|
||||
Write-Error "Could not find a interface with subnet $subnet.xx"
|
||||
}
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
if (! (Test-Path 'C:\Program Files\VMware\VMware Tools') ) {
|
||||
Write-Host "Nothing to do for other providers than VMware."
|
||||
exit 0
|
||||
}
|
||||
|
||||
|
||||
Write-Host "$('[{0:HH:mm}]' -f (Get-Date))"
|
||||
Write-Host "Setting IP address and DNS information for the Ethernet1 interface"
|
||||
Write-Host "If this step times out, it's because vagrant is connecting to the VM on the wrong interface"
|
||||
|
||||
Reference in New Issue
Block a user