VM Orchestration using Proxmox

LodgedDrip

New Member
Feb 26, 2021
21
2
3
Hi,

I'm trying to work out ways we can streamline our processes for at least creating new virtual machines on our Proxmox cluster.

At the moment, we've got a set of VMs (templates) that are cloned to make new VMs; the team has to log in via a console and then run a script which sets a bunch of things in /etc/ config, including the correct IP, and then they change the VLAN via the hardware tab, reboot and the VM comes online.

Once rebooted, they run an ansible playbook that does the rest of the installation for things like Debian packages, config changes etc.

What would be the best approach for automating the first bit of this? I've seen a few modules for Ansible that allow for some manipulation of VMs, but I'm unsure as there are articles/resources all over the place.

I could technically move the VM-based script to ansible, but then we still need to clone our VM template, get its IP address, and change the VLAN.

Any thoughts would be appreciated.
 
And you can do everything you can do using the GUI also using the Proxmox API through a script.
 
And you can do everything you can do using the GUI also using the Proxmox API through a script.
I've taken a look at the API a couple of times, but I don't think it can actually manipulate things on the VM itself? while handy to change the VLAN tag, or other settings, it doesn't seem to help with setting the VM IP or on-system config.
 
I've taken a look at the API a couple of times, but I don't think it can actually manipulate things on the VM itself? while handy to change the VLAN tag, or other settings, it doesn't seem to help with setting the VM IP or on-system config.
If you got the qemu guest agent installed you could run code inside the VM from the host using this...but I still perfer SSH for such stuff:
qm guest exec <vmid> [<extra-args>] [OPTIONS]
Executes the given command via the guest agent
<vmid>: <integer> (1 - N)
The (unique) ID of the VM.
<extra-args>: <array>
Extra arguments as array
--pass-stdin <boolean> (default =0)
When set, read STDIN until EOF and forward to guest agent via input-data (usually treated as STDIN to process launched by guest agent). Allows maximal 1 MiB.
--synchronous <boolean> (default =1)
If set to off, returns the pid immediately instead of waiting for the commmand to finish or the timeout.
--timeout <integer> (0 - N) (default =30)
The maximum time to wait synchronously for the command to finish. If reached, the pid gets returned. Set to 0 to deactivate
qm guest exec-status <vmid> <pid>
Gets the status of the given pid started by the guest-agent
<vmid>: <integer> (1 - N)
The (unique) ID of the VM.
<pid>: <integer>
The PID to query
https://pve.proxmox.com/pve-docs/qm.1.html
 

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!