If you haven't already, see the README in the root of this repository. This is the Debian-specific cloud image setup.
In short, this is what you need to run this script:
sudo ./prox-cloud-template-add-debian.sh [id] [storage] [distro] [version] [user] [password] [searchdomain] [launchpadid]
or as an example:
sudo ./prox-cloud-template-add-debian.sh 4000 SSD-01A Bullseye 11 sysadmin G00dPazz22 intranet.example.com jdoe
Below are what these values are:
id
is the ProxMox number ID you want to label this template. I'm using higher numbers and use this for metadata. For example anid
of321000
is ProxMox server 3, 2 is an arbitrary number for Debian, and 1000 represents thev10
release, with no minor version. You can use whatever you want, but it needs to be an integer.storage
is the name of the ProxMox storage device where you want to store the template. This might beLocal-LVM
or any mounted storage you have available on the same ProxMox server.distro
is the word name of the Debian version, NOT the number version. See this page as an example (e.g. "Buster", "Bullseye", etc).version
is the numeric version of the Debian version (e.g. 10, 11, etc).user
is the name of the non-root, default user who will havesudo
privilege.password
is the password foruser
, in plain-text.searchdomain
is a network setting. When you search for a server name, if it can't be found, the network stack can add-on different DNS domain suffixes to try to find the server. For example you might know "server123", but it's fully-qualified-domain-name is "server123.lab.example.com". In this case, if you set this to "lab.example.com" it will add this onto DNS queries to help file machines that you try to access.launchpadid
is the userid of the account to lookup, to scrape the SSH public keys to add to the~/.ssh/authorized_keys
file foruser
. This is a common/consistent place to store your public keys. Navigate to www.launchpad.net to create an account and upload the SSH keys from the various workstation(s) you might need to connect from.
Below is a breakdown of what this script does, and some of the nuance:
This step checks to see if the Debian Cloud Image is downloaded yet. If it is, it downloads the SHA512 hashes, makes a hash for the local file and compares them. If the hashes don't match, the image is downloaded again.
Once the image is downloaded and the SHA512 hashes match, the script continues. If this fails more than 3 times, the script errors out.
If the existing VM-ID exists, it's deleted / purged from ProxMox. This makes this script idempotent. It can be run over-and-over.
Creates the skeleton of a new VM.
Import the raw disk into ProxMox.
This attaches the Debian Cloud image to the VM.
Adds a CD-ROM.
Makes the Debian image bootable.
Need to set up TTY so that the ProxMox web-based console works correctly.
Navigate to www.launchpad.net to get your SSH public keys for whichever workstations / servers need to be able to connect to machines that are cloned from this image.
Configures all of the other details such as a description, core count, default username/password, etc.
The Debian Cloud Image is just a few gigabytes by default. This expands the /
mount point, the main disk to 120GB.
Finally, we take this VM we've been creating and change it into a ProxMox Template. The script then does some clean-up and ultimate prints out a summary message of what was built. For example:
TBD
If you have two proxmox servers, you could run something like this to set up templates for Debian Buster 10 and Bullseye 11:
# This gets run from pmvm01 as root where my SSD storage is mounted as SSD-01A:
./prox-cloud-template-add-debian.sh 121000 SSD-01A Buster 10 sysadmin P4zzw0rd123! lab.example.com jdoe
./prox-cloud-template-add-debian.sh 121100 SSD-01A Bullseye 11 sysadmin P4zzw0rd123! lab.example.com jdoe
# This gets run from pmvm02 as root where my SSD storage is mounted as SSD-02A:
./prox-cloud-template-add-debian.sh 221000 SSD-02A Buster 10 sysadmin P4zzw0rd123! lab.example.com jdoe
./prox-cloud-template-add-debian.sh 221100 SSD-02A Bullseye 11 sysadmin P4zzw0rd123! lab.example.com jdoe
I was initially inspired by this TechnoTim video:
and blog post:
I basically built-out a single script that does these things, and few other steps. This page from the ProxMox documentation was very helpful too:
As was the virt-customize
command (you need to install libguestfs-tools
first) which allows you to modify configuration of an offline VM disk: