Provision ESXi with MAAS

Key Value
Summary Learn how to deploy ESXi with MAAS. MAAS is an enterprise-grade infrastructure management tool.
Categories server
Difficulty 3
Author Andres Rodriguez andreserl@ubuntu.com

Overview

Duration: 5:00

In this tutorial, you will learn how to create MAAS images of ESXi using MAAS provided packer scripts.

ESXi support was first introduced in MAAS 2.5, but expanded in 2.6 allowing for the configuration of VMFS datastores, registration to vCenter and others. For more information about what features MAAS support, please refer to the following blog post Provisioning ESXi with MAAS: An Overview.

In order to create ESXi images MAAS leverages the use of packer, and alongside the image creation process, it introduces a series of scripts and dependencies that makes it possible for MAAS to customize each ESXi deployment, including network configuration, datastore creation and user level customization.

What you’ll learn

  • Create an ESXi image
  • Upload an ESXi image to MAAS
  • Deploy an ESXi image over the WebUI & API

What you’ll need

Getting started

Duration: 10:00

The first step is to create a working directory:

mkdir -p ~/maas-esxi

Then, move all the downloaded files (Packer, ESXi ISO and the MAAS ESXi scripts) to the working directory (In this example, we are moving them from ~/Downloads/):

mv ~/Downloads/VMware-VMvisor-Installer-6.7.0-8169922.x86_64.iso ~/maas-esxi
mv ~/Downloads/packer_1.4.2_linux_amd64.zip ~/maas-esxi
mv ~/Downloads/packer-maas-1.0.2.tar.xz ~/maas-esxi
cd ~/maas-esxi

Finally, unpack the ESXi MAAS packer scripts tarball:

tar xJvf packer-maas-1.0.2.tar.xz

Creating your image

Duration: 3:00

To create the images, ensure you are in the right directory (This is the directory where these MAAS packer files are stored):

cd ~/maas-esxi/packer-maas-1.0.2/vmware-esxi/

Then load the nbd driver. This will allow the injection of specific MAAS files into the image:

sudo modprobe nbd

After loading the driver, the image creation can be started:

sudo packer build -var 'vmware_esxi_iso_path=~/maas-esxi/VMware-VMvisor-Installer-6.7.0-8169922.x86_64.iso' vmware-esxi.json

Please note that you can watch the image creation process by opening a VNC session on 127.0.0.1:5947. The successfull completion of the image creation with result in the following output:

Warnings for build 'qemu':

* A checksum type of 'none' was specified. Since ISO files are so big,
a checksum is highly recommended.

==> qemu: Downloading or copying ISO
    qemu: Downloading or copying: file:///home/ubuntu/maas-esxi/VMware-VMvisor-Installer-6.7.0.update02-13006603.x86_64.iso
==> qemu: Creating hard drive...
==> qemu: Starting HTTP server on port 8911
==> qemu: Looking for available port between 5900 and 6000 on 127.0.0.1
==> qemu: Starting VM, booting from CD-ROM
    qemu: The VM will be run headless, without a GUI. If you want to
    qemu: view the screen of the VM, connect via VNC without a password to
    qemu: vnc://127.0.0.1:5914
==> qemu: Overriding defaults Qemu arguments with QemuArgs...
==> qemu: Waiting 3s for boot...
==> qemu: Connecting to VM via VNC
==> qemu: Typing the boot command over VNC...
==> qemu: Waiting for shutdown...
==> qemu: Running post-processor: shell-local
==> qemu (shell-local): Post processing with local shell script: /tmp/packer-shell536780074
    qemu (shell-local): /dev/nbd4 disconnected
    qemu (shell-local): /dev/nbd4 disconnected
==> qemu: Running post-processor: compress
==> qemu (compress): Using pgzip compression with 4 cores for vmware-esxi.dd.gz
==> qemu (compress): Archiving output-qemu/packer-qemu with pgzip
==> qemu (compress): Archive vmware-esxi.dd.gz completed
Build 'qemu' finished.

==> Builds finished. The artifacts of successful builds are:
--> qemu: VM files in directory: output-qemu
--> qemu: 
--> qemu: compressed artifacts in: vmware-esxi.dd.gz

The result of this is an image called vmware-esxi.dd.gz.

Uploading your image

Duration: 2:00

To upload your image, first log-in to MAAS (192.168.122.1) via the CLI:

maas login admin http://192.168.122.1:5240/MAAS/

And upload the image with the following command:

maas admin boot-resources create name='esxi/6.7' title='VMware ESXi 6.7' architecture='amd64/generic' filetype='ddgz' content@=vmware-esxi.dd.gz

You can verify the image download in the ‘Images’ tab in your MAAS:

Deploying your image

Duration: 2:00

Now that the image is available, we can go ahead and deploy a machine. In this example, we will use the machine with system_id ‘yawrmb’:

maas admin machine deploy yawrmb osystem=esxi distro_series=6.7

Or it can be done over the Web UI:

Next steps and finding help

Duration: 1:00

MAAS has been designed to be a modern, agile machine provisioning solution, enabling both physical and virtual infrastructure. MAAS can deploy Ubuntu, CentOS, RHEL, Windows and now ESXi like a bare-metal cloud. If you need help as you are using it reach out to:

Reference literature:

1 Like

I noticed in the packer .json config file that the curtin-hooks file is being tucked in partition 1 during the packer build process. Does this imply that esxi bootloader ( I’m guessing syslinux ) is going to run curtin prior to the first boot and execution of the kickstart file

How do I configure the passwords?

I was finally able to create the image without errors after installing the required submodules from git.

But now getting this error during deployment

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/curtin-hooks-1fkh013g/maas/curtin.cfg'

Edit this file before creating your image.
/maas-esxi/packer-maas-1.0.3/vmware-esxi/http/vmware-esxi-ks.cfg

I fixed my error by manually copying and renaming my image to the correct directory on maas.

Got this answer from: Deploying Vmware ESXI with ssh enabled by editing vmware-esxi-ks.cfg

It seems with the current version of packer there are some changes with the way checksums are required.

I had to run packer fix vmware-esxi.json > vmware-esxi-new.json to ‘upgrade’ the template.

Now I get “A Checksum must be specified” error here.

Error: Failed to prepare build: "qemu"
1 error(s) occurred:
* A checksum must be specified

Debug mode enabled. Builds will not be parallelized.
==> Wait completed after 3 microseconds
==> Builds finished but no artifacts were created.

I am new to both packer and MAAS, and i’m actually just trying to run a POC to see if we want to use it in future production.

I cannot seem to find the syntax to ‘specify a checksum’. Would this be put into the template itself?

MAAS ESXi packer scripts Get it here

MAAS ESXi packer scripts from the link is out of date. For correct work you should use scripts from the git

The new repo worked!

I can successfully install ESXi server but MAAS controller still thinks ESXi is being installed. Is there anyway to have it showed up as deployed?

Uploading the image into the maas gives the following error.

sudo maas admin boot-resources create name=‘esxi/6.7’ title=‘VMware ESXi 6.7’ architecture=‘amd64/generic’ filetype=‘ddgz’ content@=vmware-esxi.dd.gz
{“architecture”: ["‘amd64/generic’ is not a valid architecture. It should be one of: ‘’."]}

Several changes needed for newest releases:

After downloading the iso get the md5sum of it:

md5sum …/…/VMware-VMvisor-Installer-7.0U2a-17867351.x86_64.iso
5491860344ce79fcf2ffec2e72b79245 …/…/VMware-VMvisor-Installer-7.0U2a-17867351.x86_64.iso

Take that number, and add it to the vmware-esxi.json file (must use the correct md5sum!):

# Take out this line
“iso_checksum_type”: “none”,

# Add this line to file around line 31
“iso_checksum”: “md5:5491860344ce79fcf2ffec2e72b79245”

# Change “host” to “max”, after the “-cpu”, line, around :22
“-cpu”,
“max”

# Add allowLegacyCPU line here for 7.0+ ISOs:
“<leftShift>O”,
" allowLegacyCPU=true<enter>",

# Change the shutdown timeout to a larger number, it takes more than 20 minutes on my systems:
“shutdown_timeout”: “60m”,

I can’t get it to work with ESXi 7.0 yet, but am close. With the above changes, I get to a pink-screen-of-death:
#NM Exception 7 in world 65536:bootstrap@ 0x42002d4b8892

Perhaps someone else can take it from here?

Make sure to check the VNC while it is building, lots of good info there. Use SSH forwarding to your local machine if you are building on a remote machine.

Use the updated files from git as mentioned above:

git clone GitHub - canonical/packer-maas: Packer templates to create MAAS deployable images
cd packer-maas/vmware-esxi

# Edit vmware-esxi.json and change -cpu host to:
[ “-cpu”, “max” ],

# Add the md5sum if you want to avoid the warning:
“iso_checksum”: “5491860344ce79fcf2ffec2e72b79245”,

# Change the NIC from vmxnet3 to e1000
“net_device”: “e1000”,

Run make with the path to the ISO

make ISO=…/…/VMware-VMvisor-Installer-7.0U2a-17867351.x86_64.iso

I get this error if I don’t change the NIC to the old e1000. Not sure what issues that will cause later, but it runs at least. I see that vmxnet3 is supposed to be supported. I’m using packer 1.7.4 in Centos 8.

2021/09/01 00:16:31 packer-builder-qemu plugin: Qemu stderr: qemu-system-x86_64: -device vmxnet3,netdev=user.0: ‘vmxnet3’ is not a valid device model name

Note that the build hangs a long time at Loading /tools.t00. Wait it out, it will eventually continue, only to fail at the very end:

1 Like

I was unable to get it to complete on OS X (native), or in CentOS 8 (as a VM), but on Ubuntu 20.04 LTS native on a physical box, it completed!

Can’t get it loaded in to MAAS yet, but much closer:

root@server:/data/maas-image/packer-maas/vmware-esxi# maas admin boot-resources create name=‘esxi/7.0’ title=‘VMware ESXi 7.0’ architecture=‘amd64/generic’ filetype=‘ddgz’ content@=‘vmware-esxi.dd.gz’
usage: maas [-h] COMMAND …
(snip)
[Errno 2] No such file or directory: ‘vmware-esxi.dd.gz’

The file does exist though:

root@server:/data/maas-image/packer-maas/vmware-esxi# ll vmware-esxi.dd.gz
-rw-r–r-- 1 root root 438252695 Sep 7 23:23 vmware-esxi.dd.gz

Moving the file to /media, gives me this:

[Errno 13] Permission denied: ‘vmware-esxi.dd.gz’

Closer- It finds the file, but can’t upload it. I’m using the snap version of MAAS.

I needed none of the changes I attempted for OS X or Centos 8. Just use the git, stock.

Hi @zephrant,
The problem that you have is about using snap maas.

Snap maas only can access to /home /tmp and /media folders and subfolders (It’s a limitation of snap apps).

Put the image in your home user folder and then try to upload again.

If it works, tell me. I’m interested in deplot ESXi 7 and your experience will be useful.

Call me when this works with ESXi 8.0

So, is there anybody that has been able to deploy vmware 7 and/or 8 via MaaS. Ive been trying to deploy the iso image using the latest github canonical repo files with no luck at all.

thanks!

My Ultimate Guide to launch an ESXI 7.0 machine with vCenter 7.0 integration and MaaS 3.4 LAB ENVIRONMENT should be of help.

1 Like