Home-Lab Refresh: Hypervisors

January 2022

In the next step of my Homelab Refresh, the Hardware needed to have an OS installed. I’ve normally used CentOS as my go-to server OS, however, following the death of CentOS 8, I thought I’d try my hand with Debian.

Debian

I installed Debian manually off a USB on each node, setting up the bare minimum needed to SSH into a uniquely named host. For actual server configuration work, I used Ansible to configure the hosts as KVM hypervisors.

Since there is currently no DNS server configured as part of this refresh, the KVM hypervisors are addressed directly by IPs, the IP addresses themselves are assigned via a DHCP server running on my Mikrotik router.

Ansible

I’ve settled on using Ansible to perform the majority of the configuration for the non transient servers within the refreshed Homelab, Hypervisors included. I’ve published the initial Ansible configuration that I used to set-up KVM on these hosts. With this configuration, setting up a new SSH ready KVM node was quite easy.

Variables

ansible/group_vars/all.yml

---
# Global variables
domain: lab.alexgardner.id.au
email: alex+homelab@alexgardner.id.au

# Nameservers
nameservers:
  - '10.1.1.1'

# Client Subnet
firewall_clients_subnet: 10.1.3.0/24

# Timezone
timezone: Australia/Sydney

# Admin users
admin_users:
  - adminuser

Commands

cd ansible
ansible-playbook -i production kvm-hypervisors.yml -l kvm3

Once the Ansible playbook was run, the Hypervisors are almost ready to run VMs.

Terraform

The final KVM configuration steps are perform by Terraform. Since Terraform is being used to provision the VMs, it is convenient to have Terraform perform the final tweaks for KVM to be usable, configuring the KVM pool, network and OS images.

This allows Terraform to have easy access to these relevant bits of configuration when provisioning VMs. I’ve published the initial Terraform configuration that I used, there is also a custom Terraform module to create the VMs, however this is not currently being used.

Variables

terraform/infrastructure/hypervisors/terraform.tfvars

hypervisor_hosts = {
  "kvm1" = {
    "ip"   = "10.1.1.21",
    "user" = "root",
  },
  "kvm2" = {
    "ip"   = "10.1.1.22",
    "user" = "root",
  },
  "kvm3" = {
    "ip"   = "10.1.1.23",
    "user" = "root",
  },
}

Commands

cd terraform/infrastructure/hypervisors
terraform1.1 plan

Next up: setting up DNS