From 53587d208a77b6fcb17d5aacaecf636a852cd625 Mon Sep 17 00:00:00 2001 From: Alexsander de Souza <61709370+alexsander-souza@users.noreply.github.com> Date: Thu, 14 Sep 2023 11:59:00 -0300 Subject: [PATCH] improve ESXi build (#139) make fusefs handling more robust. review documentation --------- Co-authored-by: craig bender <19372989+ThinGuy@users.noreply.github.com> --- vmware-esxi/KS.CFG | 2 +- vmware-esxi/Makefile | 2 +- vmware-esxi/README.md | 41 +++++++++++++++++++++++++++++------------ vmware-esxi/post.sh | 13 +++++++------ 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/vmware-esxi/KS.CFG b/vmware-esxi/KS.CFG index d5493e03..e030095b 100644 --- a/vmware-esxi/KS.CFG +++ b/vmware-esxi/KS.CFG @@ -5,7 +5,7 @@ vmaccepteula # If changed be sure to update the vcenter script below. rootpw password123! -install --firstdisk +install --firstdisk --ignoreprereqwarnings --ignoreprereqerrors --forceunsupportedinstall # Sets VMware ESXi licensing key. If not included installs in # evaluation mode. diff --git a/vmware-esxi/Makefile b/vmware-esxi/Makefile index 9f8f7f99..48be1cdd 100644 --- a/vmware-esxi/Makefile +++ b/vmware-esxi/Makefile @@ -46,4 +46,4 @@ format: $(VENV) clean: ${SUDO} ${RM} -rf output-esxi vmware-esxi.dd vmware-esxi.dd.gz $(VENV) -.INTERMEDIATE: scripts.tar.xz \ No newline at end of file +.INTERMEDIATE: scripts.tar.xz diff --git a/vmware-esxi/README.md b/vmware-esxi/README.md index 9b384fdf..02f55c65 100644 --- a/vmware-esxi/README.md +++ b/vmware-esxi/README.md @@ -2,21 +2,36 @@ ## Introduction -[MAAS](https://maas.io) 2.5 and above has the ability to deploy VMware ESXi as a custom image. [MAAS](https://maas.io) cannot directly deploy the VMware ESXi ISO, a specialized image must be created from the ISO. Canonical has created a Packer template to automatically do this for you. - -## Prerequisites (to create the images) - -* A machine running Ubuntu 18.04+ with the ability to run KVM virtual machines. -* Dual core x86_64 processor supporting hardware virtualization with at least 4GB of RAM and 32GB of disk space available. -* qemu-kvm -* qemu-utils, libnbd-bin, nbdkit and fusefat -* Python Pip -* [Packer](https://www.packer.io/intro/getting-started/install.html), v1.7.0 or newer +[MAAS](https://maas.io) has the ability to deploy VMware ESXi as a custom image. MAAS cannot directly deploy the VMware ESXi ISO, a specialized image must be created from the ISO. Canonical has created a Packer template to automatically do this for you. + +## Hardware Prerequisites (to create the images) + +* A machine running Ubuntu 18.04 or 20.04 with the ability to run KVM virtual machines. +* Dual core x86_64 processor supporting hardware virtualization with at least 8GB of RAM and 32GB of disk space available. + +## Package Prerequisites (to create the images) + +* build-essential +* fuse2fs +* fusefat +* libnbd0 +* libosinfo-bin +* libvirt-daemon +* libvirt-daemon-system +* nbdfuse +* nbdkit +* ovmf +* python3-dev +* python3-pip +* qemu-block-extra +* qemu-system-x86 +* qemu-utils +* Packer - from upstream repository, v1.9.0 or newer * The VMware ESXi installation ISO must be downloaded manually. You can download it [here.](https://www.vmware.com/go/get-free-esxi) ## Requirements (to deploy the image) -* [MAAS](https://maas.io) 2.5 or above, [MAAS](https://maas.io) 2.6 required for storage configuration +* [MAAS](https://maas.io) 3.0 or above VMware ESXi has a specific set of [hardware requirements](https://www.vmware.com/resources/compatibility/search.php) which are more stringent than MAAS. @@ -35,7 +50,7 @@ make ISO=/path/to/VMware-VMvisor-Installer-8.0b-21203435.x86_64.iso Alternatively you can manually run packer. Your current working directory must be in packer-maas/vmware-esxi, where this file is located. Once in packer-maas/vmware-esxi you can generate an image with: ```shell -sudo packer init +sudo packer init . sudo PACKER_LOG=1 packer build -var 'vmware_esxi_iso_path=/path/to/VMware-VMvisor-Installer-8.0b-21203435.x86_64.iso' . ``` @@ -45,6 +60,8 @@ Installation is non-interactive. ## Uploading an image to MAAS +_Note: If using snap-based MAAS, the image to be uploaded needs reside under your home directory._ + ```shell maas $PROFILE boot-resources create \ name='esxi/8.0b' title='VMware ESXi 8.0b' \ diff --git a/vmware-esxi/post.sh b/vmware-esxi/post.sh index c8f91f2d..2a334993 100644 --- a/vmware-esxi/post.sh +++ b/vmware-esxi/post.sh @@ -1,12 +1,13 @@ -#!/bin/sh +#!/bin/sh -x echo 'Adding curtin-hooks to image...' -mount_part 1 $TMP_DIR/boot fusefat -cp -rv curtin $TMP_DIR/boot/ +mount_part 1 "$TMP_DIR"/boot fusefat +cp -rv curtin "$TMP_DIR"/boot/ echo 'Adding post-install scripts to image...' -cp -v scripts.tar.xz $TMP_DIR/boot/curtin/ +cp -v scripts.tar.xz "$TMP_DIR"/boot/curtin/ echo 'Unmounting image...' -sync -f $TMP_DIR/boot -fusermount -u $TMP_DIR/boot +sync -f "$TMP_DIR"/boot +fusermount -z -u "$TMP_DIR"/boot +grep -qs "$TMP_DIR/boot " /proc/mounts && umount -f "$TMP_DIR"/boot