Skip to content

Commit

Permalink
drop support for virtualbox
Browse files Browse the repository at this point in the history
  • Loading branch information
rgl committed Feb 11, 2024
1 parent 4822211 commit f37ef4e
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 109 deletions.
13 changes: 2 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@ SHELL=bash
VERSION=22.04

help:
@echo type make build-libvirt, make build-uefi-libvirt, make build-virtualbox, make build-hyperv or make build-vsphere
@echo type make build-libvirt, make build-uefi-libvirt, make build-hyperv or make build-vsphere

build-libvirt: ubuntu-${VERSION}-amd64-libvirt.box
build-uefi-libvirt: ubuntu-${VERSION}-uefi-amd64-libvirt.box
build-virtualbox: ubuntu-${VERSION}-amd64-virtualbox.box
build-hyperv: ubuntu-${VERSION}-amd64-hyperv.box
build-vsphere: ubuntu-${VERSION}-amd64-vsphere.box

Expand All @@ -32,14 +31,6 @@ tmp/libvirt-uefi-autoinstall-cloud-init-data/user-data: autoinstall-cloud-init-d
mkdir -p $(shell dirname $@)
sed -E 's,\*storage-config-msdos,*storage-config-gpt,g' $< >$@

ubuntu-${VERSION}-amd64-virtualbox.box: autoinstall-cloud-init-data/* provision.sh ubuntu.pkr.hcl Vagrantfile.template
rm -f $@
CHECKPOINT_DISABLE=1 PACKER_LOG=1 PACKER_LOG_PATH=$@.init.log \
packer init ubuntu.pkr.hcl
CHECKPOINT_DISABLE=1 PACKER_LOG=1 PACKER_LOG_PATH=$@.log PKR_VAR_vagrant_box=$@ \
packer build -only=virtualbox-iso.ubuntu-amd64 -on-error=abort -timestamp-ui ubuntu.pkr.hcl
@./box-metadata.sh virtualbox ubuntu-${VERSION}-amd64 $@

ubuntu-${VERSION}-amd64-hyperv.box: tmp/hyperv-autoinstall-cloud-init-data/user-data autoinstall-cloud-init-data/* provision.sh ubuntu.pkr.hcl Vagrantfile.template
rm -f $@
CHECKPOINT_DISABLE=1 PACKER_LOG=1 PACKER_LOG_PATH=$@.init.log \
Expand Down Expand Up @@ -74,4 +65,4 @@ tmp/vsphere-autoinstall-cloud-init-data/user-data: autoinstall-cloud-init-data/u
mkdir -p $(shell dirname $@)
sed -E 's,((.+)- openssh-server.*),\1\n\2- open-vm-tools,g' $< >$@

.PHONY: help build-libvirt build-uefi-libvirt build-virtualbox build-hyperv build-vsphere
.PHONY: help build-libvirt build-uefi-libvirt build-hyperv build-vsphere
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ For more information see the [Vagrant NFS documentation](https://www.vagrantup.c
On a Windows host, install [Chocolatey](https://chocolatey.org/install), then execute the following PowerShell commands in a Administrator PowerShell window:

```powershell
# NB if you want to use Hyper-V see the Hyper-V section in this document
# and do not install virtualbox at all.
choco install -y virtualbox --params "/NoDesktopShortcut /ExtensionPack"
# NB if you want to use Hyper-V see the Hyper-V section in this document.
choco install -y packer vagrant jq msys2
```

Expand Down Expand Up @@ -80,22 +78,6 @@ exit
vagrant destroy -f
```

## VirtualBox usage

Install [VirtuaBox](https://www.virtualbox.org/).

Type `make build-virtualbox` and follow the instructions.

Try the example guest:

```bash
cd example
vagrant up --provider=virtualbox --no-destroy-on-error --no-tty
vagrant ssh
exit
vagrant destroy -f
```

## Hyper-V usage

Install [Hyper-V](https://docs.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v)
Expand Down
3 changes: 0 additions & 3 deletions Vagrantfile-uefi.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,4 @@ Vagrant.configure(2) do |config|
lv.channel :type => 'unix', :target_name => 'org.qemu.guest_agent.0', :target_type => 'virtio'
lv.channel :type => 'spicevmc', :target_name => 'com.redhat.spice.0', :target_type => 'virtio'
end
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--firmware', 'efi']
end
end
13 changes: 0 additions & 13 deletions example/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,6 @@ Vagrant.configure(2) do |config|
config.vm.synced_folder '.', '/vagrant', type: 'nfs', nfs_version: '4.2', nfs_udp: false
end

config.vm.provider 'virtualbox' do |vb, config|
vb.linked_clone = true
vb.memory = $vm_memory
vb.cpus = $vm_cpus
vb.customize [
'storageattach', :id,
'--storagectl', 'SATA Controller',
'--device', 0,
'--port', 1,
'--type', 'dvddrive',
'--medium', create_cloud_init_iso_trigger(config, nil, cloud_init_user_data, cloud_init_network_config)]
end

config.vm.provider 'hyperv' do |hv, config|
hv.vmname = "#{File.basename(File.dirname(File.dirname(__FILE__)))}-example"
hv.linked_clone = true
Expand Down
21 changes: 1 addition & 20 deletions provision-guest-additions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,7 @@ set -euxo pipefail
cloud-init status --long --wait

# install the Guest Additions.
if [ -n "$(lspci | grep VirtualBox)" ]; then
# install the VirtualBox Guest Additions.
# this will be installed at /opt/VBoxGuestAdditions-VERSION.
# NB You can unpack the VBoxLinuxAdditions.run file contents with:
# VBoxLinuxAdditions.run --target /tmp/VBoxLinuxAdditions.run.contents --noexec
# NB REMOVE_INSTALLATION_DIR=0 is to fix a bug in VBoxLinuxAdditions.run.
# See http://stackoverflow.com/a/25943638.
apt-get -y -q install gcc dkms
mkdir -p /mnt
mount /dev/sr1 /mnt
while [ ! -f /mnt/VBoxLinuxAdditions.run ]; do sleep 1; done
# NB we ignore exit code 2 (cannot find vboxguest module) because of what
# seems to be a bug in VirtualBox 5.1.20. there isn't actually a problem
# loading the module.
REMOVE_INSTALLATION_DIR=0 /mnt/VBoxLinuxAdditions.run --target /tmp/VBoxGuestAdditions || [ $? -eq 2 ]
rm -rf /tmp/VBoxGuestAdditions
umount /mnt
eject /dev/sr1
modinfo vboxguest
elif [ -n "$(lspci | grep 'Red Hat' | head -1)" ]; then
if [ -n "$(lspci | grep 'Red Hat' | head -1)" ]; then
# install the qemu-kvm Guest Additions.
apt-get install -y qemu-guest-agent spice-vdagent
elif [ -n "$(lspci | grep VMware | head -1)" ]; then
Expand Down
43 changes: 0 additions & 43 deletions ubuntu.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ packer {
version = ">= 1.1.3"
source = "github.com/hashicorp/hyperv"
}
# see https://github.com/hashicorp/packer-plugin-virtualbox
virtualbox = {
version = ">= 1.0.5"
source = "github.com/hashicorp/virtualbox"
}
}
}

Expand Down Expand Up @@ -150,48 +145,11 @@ source "qemu" "ubuntu-uefi-amd64" {
shutdown_command = "sudo -S poweroff"
}

source "virtualbox-iso" "ubuntu-amd64" {
cd_label = "cidata"
cd_files = [
"autoinstall-cloud-init-data/user-data",
"autoinstall-cloud-init-data/meta-data",
]
boot_command = local.boot_command
boot_wait = "5s"
disk_size = var.disk_size
guest_additions_mode = "attach"
guest_os_type = "Ubuntu_64"
hard_drive_discard = true
hard_drive_interface = "sata"
headless = true
iso_checksum = var.iso_checksum
iso_url = var.iso_url
vboxmanage = [
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "2"],
["modifyvm", "{{.Name}}", "--vram", "16"],
["modifyvm", "{{.Name}}", "--audio", "none"],
["modifyvm", "{{.Name}}", "--nictype1", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype2", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype3", "82540EM"],
["modifyvm", "{{.Name}}", "--nictype4", "82540EM"],
]
vboxmanage_post = [
["storagectl", "{{.Name}}", "--name", "IDE Controller", "--remove"],
]
ssh_username = "vagrant"
ssh_password = "vagrant"
ssh_timeout = "60m"
shutdown_command = "sudo -S poweroff"
post_shutdown_delay = "2m"
}

build {
sources = [
"source.hyperv-iso.ubuntu-amd64",
"source.qemu.ubuntu-amd64",
"source.qemu.ubuntu-uefi-amd64",
"source.virtualbox-iso.ubuntu-amd64",
]

provisioner "shell" {
Expand Down Expand Up @@ -245,7 +203,6 @@ build {
post-processor "vagrant" {
only = [
"qemu.ubuntu-amd64",
"virtualbox-iso.ubuntu-amd64",
"hyperv-iso.ubuntu-amd64",
]
output = var.vagrant_box
Expand Down

0 comments on commit f37ef4e

Please sign in to comment.