Automating VM Deployments with Ubuntu 24.04 Cloud-Init Template
Overview
In this project, I created a reusable Ubuntu 24.04 LTS virtual machine (VM) template using the official Ubuntu Cloud Image and cloud-init configuration.
This template allows me to rapidly deploy pre-configured VMs on my Proxmox environment with minimal manual setup.
The goal was to make VM creation reproducible, consistent, and scalable, whether for personal labs, staging environments, or production services.
Why I Built It
Manually installing Ubuntu every time I needed a new VM was time-consuming and inconsistent.
Using a cloud image with cloud-init meant that I could:
-
Automatically configure hostnames, users, SSH keys, and network interfaces at boot.
-
Apply the same setup to every VM instance.
-
Save hours on setup while maintaining a standardized environment.
Essentially, this project transformed my VM deployment process from a manual installation to an automated provisioning workflow.
Tools & Technologies
-
Proxmox VE 9 (Virtualization platform)
-
Ubuntu 24.04 Cloud Image (
noble-server-cloudimg-amd64.img) -
cloud-init (for initialization)
-
SSH key authentication
Step-by-Step Implementation
1. Create a new VM

2. Set VM ID, Template Name and ‘Start at boot’ check mark.

3. On the OS tab, the boot media, i set it to ‘Do not use any media’ because later i would use the cloud-init drive.

4. On System tab i checked only the ‘Qemu Agent’, all the other options left in default values. I have to mention that qemu agent works only if is installed inside the VM.

5. For the Disk tab, i removed the default scsi0 disk because i would later mount the Ubuntu cloud image disk.

6. For CPU and Memory i set the minimum as this VM would just be a template, so i could readjust these values later.


7. The same for the Network, default values.

8. And clicked on Finish to confirm the build of the VM.

9. On the Proxmox web UI, i had to add the CloudInit drive. Hardware → Add → CloudInit Drive → default Bus/Device on IDE and VMs for Storage.


With CloudInit Drive i can pre-configure my user so on every new clone it will create i would be ready for login. Of course, i can change these values later and create a clone with a different user.

10. After that, it was time to download and mount the Ubuntu cloud image for my hard drive. From the official site i coped the link and i downloaded the image directly on my Proxmox Server.
https://cloud-images.ubuntu.com/noble/current/
(Right click → Copy Link)

11. On my Proxmox terminal, i directly downloaded the image.
# wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img

12. Next steps were to rename the image from .img to .qcow2, i named it ubuntu-server-2404 and i imported it to the template VM.
# mv noble-server-cloudimg-amd64.img ubuntu-server-2404.qcow2
# qemu-img resize ubuntu-server-2404.qcow2 32G
# qm disk import 105 ubuntu-server-2404.qcow2 VMs

13. Importing the disk on my VM i hade to do some configurations before i attach it. Hardware → Unused Disk 0 → Edit. Here i tick only on Discard because my VMs disk is ssd and also tick on SSD emulation and → Add.


14. Final steps were to do some last configurations and the machine was ready. Under Options → Boot Order →i enabled my scsi0 disk and moved it in first place so the machine could boot from this drive.


15. At this point i could just Right click on my ready vm and ‘Convert to template’ and i had have a ready for deployment Ubuntu 24.04 template. But i wanted to install some software and make my custom configurations so i waited a little bit.

Software installation and custom configurations
I connected with SSH on the fresh created VM and installed some software. My ip is:


sudo apt update sudo apt install zsh nfs-common qemu-guest-agent
chsh -s $(which zsh)
Install Oh-My-Zsh
sh -c ”$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)”
Install ‘zsh-syntax-highlighting‘ and ‘zsh-autosuggestions‘, very useful zsh plugins.
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
Made some changes to ~/.zshrc file. I change the theme of the zsh, filled in some more plugins and made some alias commands.
nano .zshrx



Ctrl + o (Save), Ctrl + x (Close)
source .zshrc
And finally,i had a very beautiful and efficient shell, ready for every kind of production.

Before shutting down and converting the VM on template
Before shutting down and converting the VM on template i had to clean the machine id so every new clone that i would make to be clear as for hardware.
sudo cloud-init clean
sudo rm -rf /var/lib/cloud/instances
sudo truncate -s 0 /etc/machine-id
sudo rm /var/lib/dbus/machine-id
cat /etc/machine-id
Must return empty
Now, my VM was ready for shutting down and → Convert to template
Benefits & Outcomes
-
Rapid Reproducibility: New VMs are ready within seconds, pre-configured and secure.
-
Consistency: All instances share identical base settings, ensuring predictable behavior across environments.
-
Scalability: Ideal foundation for automated deployments with Terraform, Ansible, or Kubespray.
-
Simplicity: No more ISO installations or manual partitioning.
-
Security: Passwordless SSH setup with pre-configured sudo privileges.
Lessons Learned
-
Using cloud-init managed to have zero to little errors that could break provisioning.
-
Automating initialization encourages infrastructure-as-code thinking, paving the way for tools like Terraform.
Conclusion
Creating an Ubuntu 24.04 VM template with cloud-init turned a tedious process into a fully automated, reproducible workflow.
This setup is now the backbone of my home lab VM provisioning — whether I’m deploying a monitoring stack, a Kubernetes node, or a simple development server, I can rely on this template and other similar to deliver a clean, secure, and consistent base every single time.