Launch VMs on free ESXI
Launch VMs on ESXI (Ubuntu Xenial in an as-automated-as-possible fashion).
ansible-playbook main.yml -i hosts --ask-pass
when prompted, enter
VMs are defined under vars/vms.yml
ESXI hosts are defined under hosts
> esxi
. If you’d rather not store the admin/root ESXI user on the local “hosts” file, pass it as a parameter during execution:
ansible-playbook main.yml -i hosts --ask-pass --user=USERNAME
---
vm_list:
-
hostname: web01
fqdn: web01.home.local
ip: 192.168.1.50
clone_vm: ubuntu_xenial # Pre-existing "clone" VM
os: ubuntu-64 # VM OS Version
up: true # Whether VM is ON/OFF
hardware:
cpus: 1 # Limited by host specs
disk: 8 # Large enough to store pkgs + data
memory: 2048 # Limited by host specs
via Ansible:
ansible-playbook get_iso.yml -i hosts --ask-pass
Manually:
Run these commands on each ESXI box (with “root” level privileges)
mkdir -p /vmfs/volumes/datastore1/images
cd !$
wget -q http://releases.ubuntu.com/xenial/ubuntu-16.04.1-server-amd64.iso
This is the portion that can’t be currently automated. It involves spinning up a very resource-limited VM.
Login to the “clone” and execute the following commands:
sudo apt-get update
sudo apt-get install -y cloud-init
sudo shutdown now
The basic premise here is quite simple, but a bit tricky:
Manual Steps
Automated Steps
vars/vms.yml
file listing VM specsI’ve been a fan of ESXI for the longest time, but I’ve never had a chance to work with it on the job. I’m also a Mac mini fan and have accumulated a few over the years: they look sleek, consume little physical space, consume even less energy and are extremely quiet — hence, they are the ideal home server lab nodes.
A few years ago, I found out that you could run the free version of ESXI on a Mac mini and have managed to run pretty much everything on it (from Windows XP clients, to OSX Lion as local DNS servers, with a few Linux distros thrown in for good measure).
However, the VMWare mantra —like the mantra of all traditional IT vendors— is to still do things in a “point-n-click” way (the “pets” vs “cattle” argument). I’ve been using the AWS cloud and Vagrant for years and wanted a way to (as much as possible) drive the creation of VMs in a “cloud-like”, “code-driven” fashion. Hence, this is a “pet” project (no pun intended) to get ESXI to behave as much as possible as my personal home cloud, and in the process combine the tech artifacts that I love (Mac Minis, Ansible, Ubuntu, & some good-old Bash).
There are a few solutions out there that do something similar but require a licensed-copy of vCenter — it proved to be quite a challenge to get all these pieces to work together just using free ESXI, so I’m quite satisfied with the current results. There’s always room for improvement so I’ll continue “polishing up” what I have so far.