Article
08 July 2024
- 12 min read
- 1.0K view
In this blog post, I’ll share my experience setting up a VMware homelab using Vagrant for automation. This approach allows for quick and easy deployment of virtual machines, making it ideal for testing and development environments.
Before getting started, ensure you have the following:
vagrant plugin install vagrant-vmware-desktop
Create a file named Vagrantfile in your project directory with the following content:
Vagrant.configure("2") do |config|
config.vm.box = "generic/ubuntu2004"
config.vm.provider "vmware_desktop" do |v|
v.vmx["memsize"] = "1024"
v.vmx["numvcpus"] = "2"
end
end
This configuration specifies:
To start the virtual machine, run:
vagrant up
SSH into the VM using:
vagrant ssh
You can further customize the VM by modifying the Vagrantfile. For example, to add a second network interface:
config.vm.network "private_network", ip: "192.168.33.10"
Vagrant supports various provisioning methods. Here’s an example using a shell script:
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get install -y nginx
SHELL
Using Vagrant with VMware provides a powerful and flexible way to manage your homelab environment. It allows for easy creation, destruction, and recreation of VMs, making it ideal for testing and development purposes.
Citations: [1] https://kaladin.dev/blog/vmware-homelab-automation-with-vagrant/