Programmatically creating a VM template and uploading it to proxmox from Linux?

fadeway

New Member
Oct 30, 2024
2
0
1
Hi,

I have some python scripts which use debootstrap and qemu-img to generate a debian image in various formats, such as VMDK. I then stick an OVF with the VMDK and can programmatically upload the whole thing to vmware ESXi as a template VM.

I want to implement the same thing for proxmox. AFAIK proxmox does not support OVA upload in this way. What strategy would you recommend to me assuming I want this to be fully automated and usable from a debian host?


I see two possibilities as a proxmox noob:
  1. Use the API via ansible to make an empty VM, then replace its disk with a qcow2 file. Seems hacky but easy.
  2. Generate a format that proxmox supports.
Regarding the latter approach, https://docs.ansible.com/ansible/latest/collections/community/general/proxmox_template_module.html seems promising. I see that I need either an ISO or an "openvz template", which seems to be a .tar.gz file with mystery contents (probably a disk image of some type and ovf-like description?). I dug into how my proxmox host stores its VMs and found some YAML files called "<vm_name>.conf", probably I need to generate something like that and put it into the .tar.gz?



To me the "correct" way seems to be to teach my code how to generate an openvz template, but I am new to proxmox. Am I on the right track? Does anyone here know what's needed to get proxmox to accept a .tar.gz over the API?
 
I see that on the proxmox host I could achieve what i want by simply calling
Bash:
qm importovf
, but is there an option to do this over the API?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!