Back in 2023, I automated my home lab starting with vSphere templates. I used Packer to get the job done, a process I originally documented in this blog post. It took me a few weeks of ‘after-hours’ tinkering to get everything right, and for a long time, that setup served me well.
However, as Ubuntu 22.04 aged, my ‘automated’ templates became obsolete. I found myself performing manual release upgrades to 24.04 every single time I deployed a VM—essentially nullifying the point of my automation.
It was time for a ground-up rewrite. This time, I decided to pair up with Gemini (AI) to see if it could speed up the migration. Did I ‘cheat’? Or did I just become more efficient? Honestly, I don’t care. What matters is that in just two hours, we didn’t just upgrade the script—I walked away with a much deeper understanding of Packer’s internals than I ever got from copy-pasting code snippets in the past. Here is how we tackled the jump to Ubuntu 24.04 and vSphere 8.
From BIOS to EFI
This has been probably the biggest change. I was able to move away from legacy BIOS configuration and start using EFI. In my 22.04 script, I used the “edit” method:
e<down><down><down><end>
I copied this from working scripts I found in the Internet, and I blindly took them. gemini explained to me why this was dangerous, and suggested some changes: this is the perfect example of what I said at the beginning, about using AI to also learn new things!
In 24.04, with EFI firmware, that method is known to be flaky because the menu structure can change. We switched to the GRUB Console method:
<esc><wait>c
This is much more robust because we explicitly tell the kernel where to find the
vmlinuz and initrd files. It removes the “human-like” arrow-key navigation that often fails if the screen resolution or menu order changes.Stability and “Patience”
Ubuntu 24.04 often resets the network interface after the installer finishes but before the final reboot. Without this, Packer might see the IP disappear for a split second and assume the build failed. The “settle” time tells Packer to keep calm and wait.
ip_settle_timeout = "2m"
Build Block Sophistication
Another remnant of clueless copy/paste: in the
build block of 22.04 Version I used three separate provisionerblocks just to move and chmod a script. Complex, useless, prone to errors.In the 24.04 version I used the more advanced
execute_command. Instead of manually changing permissions, we’re piping the script directly through sudo bash. It’s cleaner, safer, and follows the “Packer way” of minimal friction.The Cloud-Init Evolution (user-data)
While the different hcl files tells packer how to build the hardware, the user-data file passed to Cloud-Init defines the requirements we want for the operating system.
The
user-data file is also where I hit the most “Unspecified Errors” during my first attempts. Ubuntu 24.04 uses a new version of the Subiquity installer that is much stricter about YAML schema and storage logic.for the storage part, we simplified the configuration to just three lines:
storage:
layout:
name: direct
We tell the installer: “You’re the expert. Use the whole disk, handle the EFI partition correctly for vSphere, and just give me a standard root filesystem.”
Another frustrating error was the “No such user” error. The VM would boot, but I couldn’t log in as
ubuntu. I learned that if a password hash contains certain special characters (like $ or .), the YAML parser can get confused. The fix was simple but non-obvious: always wrap the password in double quotes. The previous script didn’t, and I was just lucky probably that it worked even without.Finally, the 24.04 installer tries to update itself as soon as it gets a network connection. In a vSphere environment, if the DHCP lease is a few seconds late, this “refresh” fails and stops the whole installation. We added a kill-switch for this behavior to ensure the installation remains offline and predictable.
autoinstall:
version: 1
refresh-installer:
update: no # Prevent the installer from crashing on network blips
Final Thoughts
Looking back at the two hours it took to fix this, I realized that I didn’t just upgrade a version number. I used AI to learn code that I didn’t fully understand before, and I now have a much clearer view of the different aspects of Packer.
Time-wise, it was certainly a shortcut, but not a learning shortcut. It was more like having a tutor that guided and corrected me, offering ideas based on a vast dataset. It acted as a finicky editor, perfect for spotting those tiny syntax errors—like the password quoting—that would have otherwise taken me days to find in documentation or forums.
Want to use my files? Find them here: https://github.com/dellock6/veeam-iac-lab
