Skip to content
Menu
Marius Serbanica – Tech Blog
  • My Tech Blog
  • About me
  • Contact Me
  • Curriculum Vitae
  • Projects
  • Current Projects List
  • Certifications
  • Home Lab
  • Self-Hosted
  • Linux Cheat Sheet
  • Linux Commands
  • Privacy Policy
  • Site Map
Marius Serbanica – Tech Blog
September 26, 2023September 26, 2023

Automating my Home lab with Ansible: Proxmox and Beyond

I will start with this – I am in NO way an Ansible expert nor do I present this as a tutorial. This is just a simple solution I found for my own home lab that I hope would be of use to others reading this 🙂

In today’s rapidly evolving tech landscape, managing a home lab efficiently is crucial for enthusiasts and professionals alike. Ansible, a powerful open-source automation tool, can be a game-changer in streamlining tasks and ensuring your home lab runs smoothly. In this guide, we’ll explore how to use Ansible to automate your home lab based on Proxmox, and we’ll also touch on how to extend these principles to cloud-based environments.

Before we dive into automation, we need to make sure that Proxmox is set up correctly. Install Proxmox on your hardware and configure your virtual machines (VMs) and containers to meet your specific needs.

sudo apt-get update
sudo apt-get install ansible

For other operating systems, refer to the official Ansible documentation.

Configuring my Inventory

The inventory file is where you define the hosts (machines) you want Ansible to manage. By default, it’s located at /etc/ansible/hosts. Open it with a text editor and add the IP addresses or hostnames of your Proxmox nodes.

[proxmox]
proxmox01 ansible_ssh_host=192.168.1.10
proxmox02 ansible_ssh_host=192.168.1.11

No onto playbooks…
Ansible playbooks are the heart of automation. They define a set of tasks that should be executed on the target hosts. (That’s what the documentation says, don’t @ me! LOL)

So this would be a basic playbook structure that you could use for Ansible –
Create a directory structure for your playbooks:

mkdir -p ~/ansible/homelab

Inside this directory, create a playbook file (e.g., homelab.yml). (I’ll add the YAML file below so you can copy/paste it directly from here and edit it to your own need) …The basic structure looks like this:

---
- name: Homelab Automation
  hosts: proxmox
  tasks:
    - name: Task 1
      # Task details go here
    - name: Task 2
      # Task details go here

Automate Tasks

Ansible modules allow you to perform various tasks on your Proxmox hosts, such as managing VMs, containers, networks, and more. Refer to the Proxmox Ansible Modules documentation for detailed usage.

To run your playbook, use the following command:

ansible-playbook homelab.yml

Now that your home lab is automated, you can easily extend these principles to cloud-based environments.

Add Cloud Hosts to Inventory

Update your Ansible inventory file to include cloud hosts:

[cloud]
cloud01 ansible_ssh_host=your_cloud_ip

Make sure you have the necessary SSH keys or credentials set up for authentication.

Adapting Playbooks for Cloud Environments

Adjust your existing playbooks or create new ones tailored for cloud services. Ansible has a wide range of modules for managing cloud resources across providers like AWS, Azure, Google Cloud, and more.

Running Playbooks in the Cloud

Execute your cloud playbooks in the same way you did for your home lab:

ansible-playbook cloud.yml

This is all I have for this little automation project, for now! >:D I’ll keep looking through the documentation and if I find other nifty things about this I’ll make a new post. Happy automating!

Share on Social Media
x facebook linkedin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join my LinkedIn Network.

Recent Posts

  • Kubernetes cluster. Why and how
  • Installing GNU-World on ircu2
  • Replacing Cloudflare Tunnel with Tailscale on a VPS
  • KASM – My main workspace RBI
  • Transforming a Mini PC into a Powerful Home Network Hub / Router/ Firewall with OPNsense

Archives

  • February 2025
  • January 2025
  • October 2024
  • May 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023

Categories

  • How-To
  • Tech Industry
  • Tech, but personal
  • Tutorials

Recent Comments

  1. IRC Lamer on Installing GNU-World on ircu2
  2. severus2231 on Transforming a Mini PC into a Powerful Home Network Hub / Router/ Firewall with OPNsense
  3. admin on Mounting a NAS (Network Attached Storage) device on Linux
  4. abL on Mounting a NAS (Network Attached Storage) device on Linux
  5. Alin R on Cleaning up your Linux OS.
Social Media
Find me on social media
Facebook Twitter Instagram LinkedIn

©2025 Marius Serbanica – Tech Blog