Proxmox Automation with Packer/Ansible/Kestra

fansec

New Member
Jul 30, 2024
3
1
3
Hello!

I want to share a small home project I’ve been working on for the past few months. I was looking for solutions for a certain implementation for packer and ansible on the forum, but I couldn’t find it here or in any GitHub repos.

I used Packer for template creation because it gives a granular control over creating templates compared to qm. I used Cloud-Init and Cloudbase with ISO mounting to create templates for Ubuntu Server and Desktop 24.04, as well as Windows 10 and Windows 2019. It’s pretty straightforward to adapt this setup for other OS versions as well. I’m deploying the templates with Ansible, which makes it easy to scale the way I’ve built it.

After testing a few different tools, I chose Kestra as the main automation layer. It has a lot of benefits compared to other solutions I tried, although it took me more than a month to test, understand and play with other solutions.

Basically, you create the templates, deploy VMs, and remove them as needed. The setup includes a static file that’s dynamically updated with hardcoded VM IDs, so you know exactly what to delete to clean up. There’s also a playbook to provision hosts after VM creation, allowing you to set up an entire infrastructure. With Kestra, you can create a topology that handles template creation, deployment, and provisioning in a single flow, with tasks running sequentially or in parallel. So this is a skeleton that can be used to build more complex setups and doesn't require a lot of user interaction. All the plugins needed for ansible or packer are downloaded within kestra container that is defined on the host you run.

The main reasons I created this were for reusability and ease of use in different use cases.
To deploy: have the ISOs for the templates ubuntu 24.04 server/desktop, win2019,win10x64 quemu agent, have a host in your network that can reach proxmox, docker and docker composer and edit the creds for your proxmox.

I hope this helps someone!

https://github.com/fansec/proxmox_dev
 
Hi there. Thanks for sharing this! Just what I was looking for. I just started a new project and want to be able to use at much automation as possible to setup VMs and run a kubernetes cluster.
 
Nice work, but i'm unable to get to it work for the Windows10 - I modified the credentials, storage and so on, downloaded cloudinit msi file to the mount folder in the win10 directory, the VM is creating, but the process hangs at " ==> proxmox-iso.win10: Waiting for WinRM to become available... ", while in the VM console it appears to be waiting for a keyboard input on the language selection screen.
Any ideas what am i doing wrong?

TIA
 
Hi, thanks for feedback; cloudbase.ps1 will download the msi, and it's called in autounattend. Only things you need are the ISO for win and qemu_agent.iso - qemu iso is similar to vmware tools
VM console it appears to be waiting for a keyboard input on the language selection screen
This is due to autounattend.xml, when there is a error it will hang similar to running packer on esxi for example. The issue is ISO not compatible with autounattend. Things on why it could fail:
ex. you have en-GB version of windows or another language in this case you do a search replace en-US with your language, ImageInstall has another structure etc. for Image install use tools like dism to get the index, I had an image with more versions, home, edu, pro etc Index 6 was for Windows 10 Pro and generic testing key is also for that version

To fix this, try another win10 x64 iso; take another autounattend from github there are plenty of them, that's what I did; modify to the iso you have; or you can generate an autounattend.xml with online tools or offline based on your iso. If you create or change it to antoher make sure to the the commands from SynchronousCommand
 
Last edited:
  • Like
Reactions: pear235
Hi, thanks for feedback; cloudbase.ps1 will download the msi, and it's called in autounattend. Only things you need are the ISO for win and qemu_agent.iso - qemu iso is similar to vmware tools

This is due to autounattend.xml, when there is a error it will hang similar to running packer on esxi for example. The issue is ISO not compatible with autounattend. Things on why it could fail:
ex. you have en-GB version of windows or another language in this case you do a search replace en-US with your language, ImageInstall has another structure etc. for Image install use tools like dism to get the index, I had an image with more versions, home, edu, pro etc Index 6 was for Windows 10 Pro and generic testing key is also for that version

To fix this, try another win10 x64 iso; take another autounattend from github there are plenty of them, that's what I did; modify to the iso you have; or you can generate an autounattend.xml with online tools or offline based on your iso. If you create or change it to antoher make sure to the the commands from SynchronousCommand
Indeed that was it, wrong OS locale. Redownloaded an en-US version and it worked, thanks for your help.