[SOLVED] automate deployment of VMs from cloud images

lethargos

Well-Known Member
Jun 10, 2017
142
6
58
74
Hello,

Does anyone know a way of reasonably automating the deployment of an ubuntu vm starting from the cloud-image?

I'm mostly referring to this part:
https://pve.proxmox.com/wiki/Cloud-Init_Support
Code:
# download the image
wget https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img

# create a new VM
qm create 9000 --memory 2048 --net0 virtio,bridge=vmbr0

# import the downloaded disk to local-lvm storage
qm importdisk 9000 bionic-server-cloudimg-amd64.img local-lvm

# finally attach the new disk to the VM as scsi drive
qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-1

Does the proxmox api support this? Would I be able to do it with packer, for example? All the tutorial I've come either type in the commands manually or use packer with a standard iso, which takes quite a lot of time.
 
Yes, you can do most of it via API. The only thing that is not available via API, _yet_, is "importdisk".

I've placed a script similar to what you are looking for in this thread https://forum.proxmox.com/threads/concurrent-cloning-of-vm.97549/#post-422356



Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
Yes, thank you :)

That actually boils down to: no, you cannot do it using the API. importdisk is obviously essential to it, so you have to use hacks :)
I think I prefer executing the bash script over ssh with packer and see how it goes.
That's useful stuff though - what you did there :)
 

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!