Image based provisioning with Proxmox and Packer

I recently started looking at provisioning hosts through the Proxmox plugin based on an image created with Hashicorp packer. I’m mostly wondering if anyone on the forum has a similar (working) setup and/or if they could point me in the right direction for such a setup.

Problem:
I seem to be doing something wrong, because the resulting image is provisioned with an empty disk of 8GB and the template’s disk is marked as ‘Unused’.
The VM itself has no valid boot options. This doesn’t change when I add the unused disk back in.

The 8GB disk seems to be added regardless of whether I remove it during host creation.
I noticed the cloudinit iso created by foreman is not recognized as a Cloudinit Drive, can’t say if this is an issue. I mounted the created iso in my proxmox shell and see the expected files and I can’t test whether it’s detected on the provisioned host due to no valid boot options.

Expected outcome:
The flow in my head goes like this:
I would use packer with cloud-init to setup a template that went through installation and installed some additional packages. I would then import the template/image into Foreman. Then on creation I want to use the proxmox user data provisioning template to setup the network interfaces and puppet related config.

Foreman and Proxy versions:
3.14
Foreman and Proxy plugin versions:
fog-proxmox (0.15.1)
foreman_fog_proxmox (0.18.1)

Distribution and version:
AlmaLinux 9.5
Other relevant data:
It’s my first attempt at provisioning in general, so I hope that I’m just missing some steps in my flow.
I’m using a 3 node Proxmox 8.4.1 cluster with ceph. While there is an open issue on the plugin’s github regarding the version support, I don’t get the any of the errors reported on that issue. There are some bugs I workaround for my ceph/cluster setup, but in the end the VM is created. Blank, but created.

The packer image is Ubuntu 24.04 with cloud-init.

Did you use the same hard disk for image and vm ? For example, virtio0 for both image template and host? Because then it will rewrite the image harddisk while creating the host.

1 Like

You’re right! That is the case!
I changed the template to set it to virtio1, I initially tried to set my compute profile to not make any hard disk, but it always made at least one. Also, if I added a disk to the profile, I can’t delete it anymore, it would just reappear every time I finished removing it. I believe this may be a bug.

In any case, the VM now runs. It still has the empty 8GB disk, but it’s progress so will deal with that later.
The current problem is the cloud-init iso, it doesn’t seem to recognize the generated iso.
Do you have an idea what causes that?

The template picks its own iso up as a cloud-init type
image

The default hard disk addition is as designed. You need at least one hdd in for VM to run so it will check if there is no HDD in VM then it will add it.

Can you please check the boot order is correct? What do you mean it isn’t recognizing the iso? Can you please post the errors you are getting?

1 Like

The default hard disk addition is as designed. You need at least one hdd in for VM to run so it will check if there is no HDD in VM then it will add it.

Makes sense, I might have to change my flow then, because the template already has a disk that’s good to go.

What do you mean it isn’t recognizing the iso? Can you please post the errors you are getting?

I spoke too soon again. :sweat:
In the logs I see that it does recognize the cloud-init, but it errors out to

2025-04-25 09:31:44,067 - schema.py[WARNING]: Invalid cloud-config provided: Please run ‘sudo cloud-init schema --system’ to see the schema errors.

Which leads to the cause:

Invalid user-data /var/lib/cloud/instances/may-watsky.example.net/cloud-config.txt
Error: Cloud config schema errors: users.0.hashed_passwd: None is not of type ‘string’

I didn’t add a password on the image in Foreman, so the hash was null. Now that I added that, the cloud init functions and I get my puppet goodies.
Thank you very much. You basically solved my issue!

I wonder what I should do with the empty 8GB disk on host creation, you don’t happen to have experience with this type of setup (packer image with foreman) to point me in the right direction? :sweat_smile: