Infrastructure

Automated KVM VM Provisioning with Ansible and OSBuild on RHEL9

Automated KVM VM Provisioning with Ansible and OSBuild on RHEL9 #

Introduction #

When I started looking into automating my homelab VM provisioning, I was surprised by the lack of examples combining Ansible with OSBuild for KVM environments. Not many tutorials focus on KVM, so I wanted something that used Red Hat’s tooling - as I run a RHEL homelab.

I used to provision my homelab virtual machines by hand and eventually I got tired of doing it since I like to tinker around a lot and constantly add new VMs. So, I decided to automate the process using the combination of Ansible and OSBuild.

Enable EPEL Repository on RHEL9

Enable EPEL Repository on RHEL 9 #

The EPEL repository provides packages that are not included in the standard RHEL repositories, such as htop and vim for example.

Prerequisites #

Before installing EPEL, you need to enable the CodeReady Builder repository, which provides dependencies for many EPEL packages.

Installation Steps #

Enable codeready builder repository #

subscription-manager repos --enable codeready-builder-for-rhel-9-$(arch)-rpms

Install epel-release #

dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm

Verification #

After installation, you can verify that EPEL is enabled by listing available repositories:

Extending LVM Partitions

Extending LVM Partitions #

This guide walks you through extending LVM partitions when you’ve added new disk space to your system.

LVM Structure #

LVM operates with three main components:

  • Physical Volumes (PV): The actual disk partitions
  • Volume Groups (VG): Collections of physical volumes
  • Logical Volumes (LV): The volumes you mount and use

Common Scenario #

You’ve added disk space to a virtual machine and need to extend the root filesystem. This is a common requirement in virtualized environments where storage needs grow over time.