Server Templates

In order for customers to select an operating system when creating their servers, VM templates must be created on the Proxmox host.

Templates are technically cloud-init based images that are just converted to a Proxmox template.

Script

I’ve put together a small script that will help you execute a few commands at once, download it with the following command:

root@dev-01:~# wget https://cdn.bennetgallein.de/products/ProxmoxCP/bin/build-image.sh -O build-image.sh && chmod +x build-image.sh

See the help:

Proxmox cloud-init importer script 0.1.0
(c) 2024 bga.sh/web

Options:

-l
     list available operating systems
-h
     show this help
-o "Debian 12"
     build for the following operating system
-s local-lvm
     select the storage in which to save the template in
-i 9000
     VMID for the template. "next" can be used to fetch the next free ID
     from Proxmox
-c 1
     amount of CPU cores
-m 512
     amount of memory
-b vmbr0
     bridge to use
-g
     install the guest agent
-n
     dont't automatically convert at the end

example:
     ./build-image.sh -o "Debian 12" -s zfs -i next -c 1 -m 512 -b vmbr0 -g

Executing the command ./build-image.sh -o "Debian 12" -s zfs -i next -c 1 -m 512 -b vmbr0 -g will do the following things:

  1. download the latest Debian 12 cloud-init qcow2 file into a /tmp storage
  2. imports the qcow2 into the storage named β€œzfs”.
  3. uses the Proxmox API to get the next free VMID
  4. uses 1 core and 512MB of memory
  5. uses the vmbr0 network bridge
  6. install the qemu-guest-agent

Manual

I will show you how to set up a Debian 10 template here. I use the terminal for almost all steps.

First, log in to your Proxmox host via SSH.

root@dev-01:~# wget https://cloud.debian.org/images/cloud/buster/20200803-347/debian-10-generic-amd64-20200803-347.qcow2
root@dev-01:~# qm create 9001 --name "debian-10-cloudinit-template" --memory 2048 --net0 virtio,bridge=vmbr0
root@dev-01:~# qm importdisk 9001 debian-10-generic-amd64-20200803-347.qcow2 local-lvm
root@dev-01:~# qm set 9001 --scsihw virtio-scsi-pci --scsi0 local-lvm:9001/vm-9001-disk-0.raw
root@dev-01:~# qm set 9001 --ide2 local-lvm:cloudinit
root@dev-01:~# qm set 9001 --boot c --bootdisk scsi0
root@dev-01:~# qm set 9001 --serial0 socket
root@dev-01:~# qm template 9001

First, download the Debian 10 cloud image from the Debian CDN. Debian is not the only vendor to offer such templates. It should be easy to find them for other vendors as well. Then you create a VM with the ID 9001 (the ID can be random, but I use the 9000+ range as it is unrealistic that I will ever create so many VMs). Then you import the image into local-lvm, which Proxmox uses as a storage location. In the last step, you convert the VM to a template so you can use it in Proxmox.

You want a clean name in the selection list. Therefore you have to change the name of the template.

template_1.png

The CP replaces all "-" with spaces, so to get "Debian 10" you have to name the template "Debian-10".

Managing Templates

Some templates may have some requirements that differ from the normal use-case. For example, you might have a template ready setup that contains a Database which might need more memory than the lowest possible option. In order to make life easier for you and your customers, you can configure certain aspects of a template directly in the Panel.

manage_templates.png

Here you can see the options that you can set. The display name is the name under which the template will be shown to the customer during the order-process and on his server overview page.

With the next 3 fields you can customize what requirements the template has. So you might want to signal to the customer that the server needs to have at least 4 cores, 16GB of Memory and 150GB of storage, which you can set as a minimum requirement here.

You also get to choose the default disk, which is the disk that will be resized during the creation of the server. There are most likely multiple disks here, but you need to choose the correct one.

You can also change the cloud-init user which is used during the creation. If nothing is set here, the default user β€œroot” will be used. Warning: this does not change the user in the template itself, but if a template provides a non-changeable default user, you can change it here.

support

Do you require help?

Wether you have encountered a Bug, ran into a problem setting something up or require generall assistance using some of the features, we want to help you with that.

On our Discord-Server you can ask for help of any kind, suggest new ideas for our products or just hangout and chat!

Open Discord