[SOLVED] Configuring cloud-init via API

mr_art

New Member
Jan 17, 2025
2
0
1
I am struggling to configure cloud-init via the Proxmox REST API.

I would like to create a VM and customize its cloud-init. The built-in Proxmox cloud-init options (ciuser, cipassword, etc) do not have enough flexibility (for example I can't use it to install qemu-guest-agent).

You can configure cloud-init via a snippet, but there is no way to upload a snippet via the REST API.

You can configure cloud-init via a custom ISO, which *can* be uploaded via the REST API. Unfortunately, it seems that Proxmox recognises when you've attached a custom cloud-init ISO, and tries to help by regenerating the cloud-init ISO when starting the new VM, but this fails

generating cloud-init ISO
TASK ERROR: command 'set -o pipefail && genisoimage -quiet -iso-level 3 -R -V cidata /run/pve/cloudinit/100/ | qemu-img dd -n -f raw -O raw 'isize=0' 'osize=67584' 'of=/var/lib/vz/template/iso/vm-100-cloudinit.iso'' failed: exit code 141

Is there a way around this? I want to use only the REST API.
 
Hi @mr_art, welcome to the forum!

Currently, full API support for managing custom CloudInit snippets is not yet available.

There has been ongoing demand for this feature over the years - for example, see this discussion: Proxmox Bugzilla #2208.

As far as I’m aware, there’s no immediate resolution or official support for API-based uploads of custom snippets, though that may change in the future.

In the meantime, the best approach is to find an alternative method to push the snippet or customize the snippet template, and then assign it to the VM via API.

Another option is to implement an external CloudInit service (similar to OpenStack). For example, you could run an HTTP service and configure your template to fetch the snippet dynamically over HTTP.

Good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Thank you for the speedy reply.

It turns out, renaming the custom ISO from vm-100-cloudinit.iso to vm-100-cl00udinit.iso was enough to fool Proxmox into ignoring the cdrom drive for cloud-init purposes. So I assume Proxmox is somehow scanning the ISO name for the string "cloudinit".