Packages directive in cloud init drive?

Swappage

New Member
Apr 29, 2023
7
0
1
Hello everyone,
I've lurked around the forum and searched by I couldn't find any information about this: is it possible (or is there any plan of adding) to add a packages directive in cloud init ?

I'm planning to automate the deployment of some VMs by keeping the footprint of the template as small as possible so that i can clone them very quickly or even use terraform for such purpose.

Unfortunately I couldn't find a way to automatically install packages using cloud init.

Can anyone point me to a source of informations on how and if it's possible to do so?

Thanks very much.
 
  • Like
Reactions: Swappage
oh :)
This is very interesting but I don't understand what it means when the wiki says "the filesystem needs to support snippets"
Also, if i configure the template to use these custom configurations, will the cloned VMs carry the configuration over?
what happens, for instance, if i have to change something specific in the cloned VM? will this effect my template files as well?
 
This is very interesting but I don't understand what it means when the wiki says "the filesystem needs to support snippets"
It doesnt say that. It says " storage that supports snippets". All filesystems support placement of snippets because snippets are files and thats what the filesystems are used for. Not all "storage" types support files.
Most common place for snippets in basic install is "local" storage.

Also, if i configure the template to use these custom configurations, will the cloned VMs carry the configuration over?
Yes, hence you need to make sure that you place the template in a proper "golden image" state. I.e. a lot of CloudInit configuration only runs on first boot. Additionally things like "hostname" or any customization would need to be done per clone. Trying it is the best way to find these things out..
what happens, for instance, if i have to change something specific in the cloned VM? will this effect my template files as well?
nothing that you change _in_ the cloned VM affects the template. If you mean "what happens if I change global cloud-init file that all VMs used" - it can affect other VMs. It depends on the change, VM state and few other things.

Here is an example from one of the scripts we use:
qm set $VMID -cicustom "user=$SNIPS/centos.user"
qm set $VMID -cicustom "meta=$SNIPS/$META"

as you see the "userdata" portion is common, however the metadata is per VM for appropriate instance-id and hostname :
Code:
{
"instance-id": "2000",
"local-hostname": "vm2000"
}

Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
Last edited:
ok
i'm doing some testing right now
i've already noticed that i'll need to change the hostname for every clone i make, which means most likely i'll have to create a custom cloud-init file for each clone anyway.
The good part of how cloud-init was implemented in proxmox with that "magic cdrom" is that whenever you clone a template, the configuration like hostname (for instance) would adapt to the new VM name.

that means i can clone, expand the drive and i'm ready to power it on.
I'll try to figure out some automations for this, or i'll just end up installing packages manually
 

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!