Discussion: Proxmox + Ansible = Awesomeness

Feb 25, 2024
105
17
18
Hey guys, i am an ansible enthusisast and would like to start a discussion on your usecase and my usecase regarding ansible. I am not an ansible expert but I love utilizing ansible as much as possible. Maybe I can get some ideas and you can get some ideas from me. So here it is:

I have a vm which iis running ansible and ansble awx to automate tasks that are done over and over. After setting everything up you can save a lot of time. Like really a lot :) Here's how utilize ansible:
  • automate backups of lxc and vms
  • automate update
  • automate lxc and vm deployment
  • wake up truenas scale backup server via WOL and then start replication then shut it down when it's done to save energy
  • automate unlocking of dataset because i use passphrase for many dataset for security. (you know when HW got stolen all data is locked down)
  • automate installation of packages
  • shutdown groups of vm/lxc before truenas update then start them after update
  • etc.
For a couple vm this might not be worth it but worth learning. When my homelab started getting bigger the time I spend doing stuff over and over and doing them to ech vm/lxc was just immense and now I can do garden work again lol

How do you use ansible?
 
@Alwin Antreich Thanks for the inout! :) No i have not tried that one yet. I've always wanted to try cloud-init but never done it :p It's on my to do list though :) Sounds like you use Proxmox in the company with ansible. Do you have more ideas or suggestions for me as a homelaber?
 
Nice to hear you're having fun. Have you tried utilizing cloud-init with ansible-pull yet?
Well, cloud-init alone can automate the initial installation of the VM and ansible gets the rest done. We use it in our infra. :)
I'm in the process of trying to build a playbook that I run locally (and in the future from AWX with a Survey to change the VMName and VMID) that uses a cloud-init image to fully deploy a "current" OS that is ready to add "roles" to. I seem to be seeing a lot of "plays" that run directly on the PVE host. Do you have a link or a playbook to share that will accomplish this remotely?
 
I'm boring. I just use it to keep my proxmox nodes, VMs and LXCs up to date, to reboot when a new kernel is installed and to run apt autoremove as needed.
 
i use ansible to install okd and all the components needed for the install on proxmox, which contains setting up dns dhcp tftp server with all necesarry prerequisites and then bootstraps a full okd install via UPI

okd does some way of cloud init, so i do cloud init, but not via the proxmox ui

but till yet i do not use ansible to update proxmox itself, which sounds like a good idea to implement :)
 
Last edited:
Isn't unattended-upgrade doing this already? Never used ansible to update stuff.
Yes, I could do it that way. I could also do it with a shell script. But, with Ansible, I learned a new skill, I can trigger an automatic reboot after a new kernel install and I can automatically remove unused kernels. Plus I can extend it to do other tasks for me in the future.
 
  • Like
Reactions: homelabenthusiast
In Ansible your imagination is the limit :p It is just very powerful that you can also wipe your entire homelab if not done correctly :p
 
In Ansible your imagination is the limit :p It is just very powerful that you can also wipe your entire homelab if not done correctly :p
That's true for any programming language I ever worked with and still true for the good old shell. Ansible is nice, yet it wasn't the first and it won't be the last automation technology. Depending on the problem, I still use shell very often.
 

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!