Cloud Init Template Creation Script

andrewglass3

Member
Apr 16, 2022
1
1
8
Hi all

Haven't posted on here before but long time lurker.

Apologies if something similar to this has been posted in the forum previously.

As part of my learning with Proxmox I've wanted to learn how to build a script to create vm templates so that I can clone a template into a vm quickly. Rather than sit there waiting for an ubuntu server iso to boot, go through a manual configuration etc.

I read a script online from where I got this inspiration from, I can't remember the url where I read it but if I come across it again - I will update my GitHub repo with a link to the author as they deserve kudos for their original script. I have modified the original script and added some additional variables to give me more control than the original script gave me.

I thought I would share this here in case it could be helpful to someone else.

https://github.com/andrewglass3/ProxmoxCloudInitScript

Cheers

Andrew
 
  • Like
Reactions: modem7
Good job! Looks very clean, and great readme.

I may have to look at redoing my script so it's cleaner given yours.

This is my version of a template creation script (although it's a bit convoluted): https://github.com/modem7/public_scripts/blob/master/Bash/Proxmox Scripts/create-jammy-cloud-template.sh
I think your script is perfect, there are some minor tweaks for storage other than ZFS to get it to work and adding the addition of a function to convert it to a template automatically which wasn't to hard to set. But I like the customization of it FYI.
 
  • Like
Reactions: modem7
I think your script is perfect, there are some minor tweaks for storage other than ZFS to get it to work and adding the addition of a function to convert it to a template automatically which wasn't to hard to set. But I like the customization of it FYI.
Thank you!

I'm happy to accept PR's so that your particular use case is implemented as well!

I chose not to have it converted to template automatically as I normally add additional things on top (like ZSH, Postfix etc).

I've also thought about the SSH key as this can be simplified with:

Bash:
SSH_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOFLnUCnFyoONBwVMs1Gj4EqERx+Pc81dyhF6IuF26WM proxvms"
SSH_KEY_URL_ENCODED=$(echo -n "$SSH_KEY" | sed 's/ /%20/g; s/+/%2B/g' | sed 's/$/%0A/')

So I'll implement this at some point.
 

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!