Since most of the Beta videos that have blown up since March 31st focus on the “what’s new” aspect of Jammy Jellyfish, that will not be my focus. Instead, since Ubuntu 22.04 LTS (Jammy Jellyfish) is released this month, I thought it would be a good idea to prepare a consistent build process for VMware Fusion and/or Workstation using Hashicorp Packer .
Most existing Ubuntu + Packer articles I have come across over the last couple monts have been only on the earier versions of Ubuntu and their configs don’t quite work for this new 22.04 version.
If you are already very familiar with Packer and HCL then I encourage you to explore the Packer Examples for vSphere Github repostory maintained by Ryan Johnson and several contributors. That repo is quite advanced for those of us just getting started trying to learn Packer. I wanted/needed something quite a bit more basic and focused solely on Ubuntu so I scoured that repo and several others looking for just the right combination of code snippets to pull together exactly what “I” need. With that said, I hope my efforts here can help others getting started with Packer and Ubuntu builds for VMware Fusion and Workstation!
My goal with the set of files in my repo is to provide something simple to understand. When I started my path to learning and understanding this stuff, I was overwhelmed by some of the other repos (like the above mentioned packer-examples-for-vsphere) due to their more advanced and powerful configuration options. I hope this repo is found to be useful for others as well!
You must have the following installed/available in order to make use of this repository as-is:
- VMware Fusion (Apple Users) or VMware Worksation (Windows/Linux users)
- Hashicorp Packer (Version 1.8.0 is current as of this article)
- Access to a machine capable of running the mkpasswd command (if you need to change the GUEST_PASSWORD)
How to use this repository
The quick way
If you wish, you can simply clone the repository and run the script provided to get a quick Server VM available.
Default username: vmadmin Default password: MyP@ssw0rd-22!
The right way
As with any software/OS containing credentials, you are highly encouraged to CHANGE settings to fit your preferences
- Clone the repository
- Edit the following values in the http/user-data file:
- packages (optional)
- Edit Lines 2-11 in the build-daily.sh to fit your preferences
- NOTE: The GUEST_ENCRYPTED_PW must be updated if you change the GUEST_PASSWORD value (instructions to generate that string value are provided in the script)
- Review the ubuntu-2204-daily.pkr.hcl file, lines 10-15 and update VM specs as desired (optional)
- Once you have reviewed and edited the files to your liking, run the build-daily.sh script
About mkpasswd for step 3
Special thanks to Lolke Dijkstra for his comment containing this additional information:
The mkpasswd utility takes an optional SEED. If you generate an encrypted passwd without it, you’ ll get a different outcome each time. The seed that is uses is in the generated password, in between the 2nd $ and the third dollar. So, for example:
mkpasswd -m sha-512 --stdin admin ThisIsTheSeed
(password is admin and seed is ThisIsTheSeed) generates:
So, in your case the seed is: Da/Bin6we2OOJCVD.
So, the command:
mkpasswd -m sha-512 MyP@ssw0rd-22! Da/Bin6we2OOJCVD
which is consistent with what you have.
What does this script and Packer configuration do?
- Get the daily build of the Ubuntu 22.04 LTS Server ISO image
- Get the iso checksum of the file from the official site
- Update the config files with the ISO Checksum, Downloads Folder, Guest Username, Guest Password, and Guest Encrypted password.
- Build a new VM in VMware Fusion or Workstation (I’ve only tested with Fusion)
- Set the build/ssh user to allow sudo without prompting for password
- Resize the Logical Volume/Volume Group to use 100% of the specified disk size
- Install: openssh-server, open-vm-tools, cloud-init, whois, zsh, wget, tasksel