Configuring hookscripts to run for all VMs? Or for all VMs cloned from an image template?

victorhooi

Well-Known Member
Apr 3, 2018
252
20
58
38
I have been trying to find a way to script things for VM creation/shutdown, and hookscripts seem close to what I have been looking for!

https://pve.proxmox.com/pve-docs/pve-admin-guide.html#_hook_scripts

However, in our workflow - we have multiple image templates setup (e.g. Windows 7, Windows 8.1, Windows 10), and people use this to spin up new VMs for testing as needed.

From the documentation - it seems like hookscripts need to be manually setup in the config file, for each new VM.

However, we would like a hook to trigger every time a VM is spun up (either for all VMs, or if possible for all VMs from a given template).

Is there any way to do this with the current technology in Proxmox?
 
Put the hookscript on a storage that's available on all nodes those VMs run on. Add the hookscript to the VM and create a template from it. Now every new clone will have it configured.
 
We have a 3-node HA Proxmox cluster, with Ceph.

So could we store the hookscript on CephFS? Or is some external SMB storage a better idea?

And you're saying if we add it to the config textfile by hand on the image, then create an image template from that via the GUI, it should propagate through to all VMs cloned from that template?
 
Any storage that's shared and available on all nodes and supports snippets should be fine.

Every clone that is done after adding the hookscript to the template should have it in its config.
 

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!