Proxmox Lab with Ansible
Imagine managing your homelab infrastructure with enterprise-level precision, all without the complexity of Terraform pipelines. That's exactly what this project is about.
In this article, I'll guide you through ansible-pve-lab repo - https://github.com/tylalin/ansible-pve-lab, a sleek, Ansible-driven workflow designed to automate the deployment and configuration of QEMU KVM virtual machines on Proxmox VE. Whether you're setting up a new small lab or expanding a comprehensive service mesh of VMs, this repository provides an opinionated, yet incredibly flexible, method for orchestrating your Proxmox environment using only YAML and Ansible playbooks.
No more battling with Terraform. No need for additional orchestrators. Just the power of Ansible, the simplicity of Proxmox's CLI, and a workflow that's clear and repeatable. Although there is a module called proxmox_kvm, it's preferable to use the SSH key authentication rather than API token and password. Plus the Proxmox's CLI is quite powerful to manage any resource for virtualisation.
Prerequisites
3-node Proxmox VE with or without cluster and Ceph storage setup
SSH key authentication for root account on each node
Ansible controller node
Proxmox Configuration
There are three nodes in this Proxmox setup as below.
pmx1:
192.168.100.101pmx2:
192.168.100.102pmx3:
192.168.100.103

Ansible Setup
Configuration
Following is how the environment configured locally for Ansible.
Inventory
Here is how Ansible inventory looks like for the lab.
It's designed to create each virtual machine on respective Proxmox VE node with its relevant VM specification.
Role
The workflow has been created as an Ansible role in order to integrate with any other roles in the future. It's called pve_manage_vm.
Playbook
To consume the role, a simple playbook called deploy.yml has been setup as below.
Build
We can consume the playbook as following to automate QEMU KVM VMs creation on multiple Proxmox VE nodes.


Teardown
To clean it up, run the following command.


Conclusion
And there you have it. We've journeyed through the core of ansible-pve-lab, a testament to what's possible when the power of Ansible meets the robust capabilities of Proxmox VE. No longer are you bound by manual configurations or the intricate web of complex orchestration tools. Instead, you've unlocked a world where your homelab - whether a burgeoning cluster or a sprawling service mesh - operates with the precision, efficiency, and repeatability of a top-tier production environment.
This isn't just about deploying VMs; it's about reclaiming your time, empowering your innovation, and building a foundation for experimentation that's as solid as it is flexible. With pure YAML, elegant Ansible playbooks, and the straightforward command-line interface of Proxmox, you now possess the blueprint to not only manage, but truly master your virtualised infrastructure.
The journey of automation is continuous, and this framework provides a powerful launchpad. Adapt it, expand it, and let it be the catalyst for your next great homelab adventure. Go forth, automate, and build with confidence - your epic homelab awaits!
Last updated
Was this helpful?