Skip to content

avojak/homelab

Repository files navigation

homelab

This repository contains the configuration-as-code for my homelab.

The goal is to automate as much as possible to a reasonable extent. This means that there will be manual intervention involved, such as plugging in IP addresses after VMs are provisioned, and some application configuration after installation.

Prerequisites

1. VMware Workstation

For the Packer builds to work you will need VMware Workstation (or Fusion if you're on macOS) to be installed.

2. ESXi Hosts

  • SSH access must be enabled temporarily on the ESXi host when running Terraform. (Don't forget to disable this when you're done!)
  • By default, Terraform expects a virtual network named "VM Network" (Created by default when ESXi is installed)
  • By default, Terraform expects a disk store named "datastore1" (Created by default when ESXi is installed)
  • By default, Terraform expects an ESXi user "root" and access on port 22 (Created by default when ESXi is installed)

For all hosts it's a good idea to configure ntpd to start/stop with the host, and set a network time server (e.g. time.nist.gov).

ARM Hosts

For the Raspberry Pi ESXi host(s) that you will be using to build the OVA templates you will need to enable GuestIPHack on the host:

esxcli system settings advanced set -o /Net/GuestIPHack -i 1

3. Terraform ESXi Provider

To use Terraform with ESXi without vCenter (because $$$), I used terraform-provider-esxi.

The terraform-provider-esxi executable should be placed in the terraform/ directory.

Usage

Initialize Prerequisites

This will initialize Terraform, fetch the providers listed in terraform/versions.tf, and generate an SSH key for Ansible to use.

$ make init

Packer

Packer is used to build the base VM images.

$ make image

This is a good time to make a cup of coffee - it'll take a while.

The output .ova images will be placed in ./packer/output/.

Terraform

Terraform is used to stand up the VM hosts on ESXi.

$ make plan-deploy
$ make deploy

If needed, you can destroy the VMs created with Terraform by using:

$ make undeploy

Ansible

Ansible is used to configure the VM hosts.

$ make install

In following with Ansible principles, this command can be run repeatedly to ensure constant state and apply any updates.

Landscape

Homelab Architecture


References


Issues & TODOs:

[ ] Setup a different datastore for the Pi host that's building the templates so we don't take up disk space from VMs [ ] Unable to resize the boot volume for the arm64 templates [ ] Auto resize root volume: https://askubuntu.com/a/937351/919056


Update ESXi hosts:

https://www.vinchin.com/vm-tips/esxi-update-upgrade.html

esxcli system maintenanceMode set -e true
esxcli software vib update -d /vmfs/volumes/datastore1/VMware-ESXi-7.0U3o-22348816-depot.zip --dry-run
esxcli software vib update -d /vmfs/volumes/datastore1/VMware-ESXi-7.0U3o-22348816-depot.zip
esxcli system shutdown reboot -r "ESXi system upgrade"
esxcli system maintenanceMode set -e false
vmware -v
esxcli software profile update -p ESXi-7.0U3o-22348816-standard -d https://hostupdate.vmware.com/sof
tware/VUM/PRODUCTION/main/vmw-depot-index.xml

About

Infrastructure and configuration-as-code for my homelab

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published