Lab Time: Setup with Vagrant on VMware Fusion/Workstation
In this post, I’ll guide you through the seamless deployment of laboratory (lab) environments on VMware Fusion or Workstation using Vagrant. The primary objective is to create a versatile, multi-purpose lab environment ideal for testing cloud-native solutions, prototyping integrations, exploring automation, and refining workflows.
The importance of a Lab
A lab, whether it’s a full-scale environment, a miniaturized version, or a portable setup, holds significant value for infrastructure administrators, platform engineers, and developers. It serves as a crucial space for testing technologies before implementation in a production environment. While a lab is not a direct Proof of Concept (POC), it provides a controlled space for decision-making without impacting operational environments.
For this reason, a good lab should:
- go straight to the objective without wasting time with long and interactive installation processes
- repeatable, using a good automation level to reproduce, destroy, and rebuild the environments
- recoverable, the essential data should be protected in case of deep system corruption
- secure, with networking and infrastructure isolation from the production environment to avoid unwanted interactions and guarantee enough protection to work safely with your platform.
Acknowledgments
Special thanks to the vExpert program and Cohesity for providing the hardware: a fanless mini PC Maxtang NX 6412, equipped with an Intel Elkhart Lake J6412 Processor and 32 GB RAM. This “portable lab” serves various needs and can run on Windows/Linux or as a portable ESXi host. For those curious about setting up ESXi, refer to Vladan’s post here.
So here thanks again to Cohesity and the vExpert program for this gift!
Note: the following “instructions” can be applied also to other systems, like Mac or different mini servers. Just minds to have enough CPU and Memory to run an Intel Virtual Machine with 2vCPU and 8GB RAM.
Getting started!
Following the ingredients:
- A PC/MAC with enough resources to run Workstation/Fusion (in this case I’m using the minilab got as present during VMwareExplore 2022)
- VMware Fusion/Workstation (If you’re a vExpert you can have a 365days license for free)
- HashiCorp Vagrant: https://www.vagrantup.com/
- HashiCorp Vagrant for VMware Fusion/Workstation (to make Vagrant connect with the VMware instance running in your device, it’s necessary to install and execute a specific provider. You can follow the official guide or clone the official project on GitHub: https://github.com/hashicorp/vagrant-vmware-desktop )
- Git CLI to clone the repo: https://github.com/linoproject/basic_lab_setup
After installing VMware Workstation or Fusion, the next step is to prepare your environment for automation. Follow these steps:
- Install Vagrant Community and Vagrant VMware Utility:
- Vagrant Community Installation
- Vagrant VMware Utility Installation
- Execute the command:
vagrant plugin install vagrant-vmware-desktop
- Set Up Git CLI and Visual Studio Code:
- Install Git CLI: Download Git CLI
- Install Visual Studio Code (optional): Download Visual Studio Code
- Clone the Repository:
- Use Git CLI to clone the lab setup repository:
git clone https://github.com/linoproject/basic_lab_setup
- Use Git CLI to clone the lab setup repository:
Then you’re ready to deploy the first lab.
Automation with Vagrant, Terraform, Ansible, …
One interesting thing behind the automation/configuration management/infrastructure as code tools is the extensive use of the following tools:
- Drone: an extremely lightweight pipeline tool that, depending on the size in terms of automation tasks can run in Docker, Kubernetes, and GitLab. With a simple YAML and a Docker/Podman instance, it’s possible to easily run pipelines and execute tasks based on containers.
- Ansible: one of the most famous configuration management systems and automation tools with a huge collection of playbooks and extensions (https://docs.ansible.com/ansible/latest/collections/index.html)
- Terraform: the standard de-facto of Infrastructure as Code, able to deliver infrastructure elements across all clouds and all platforms. In this lab, we’re gonna use the CLI version (free to use and implemented as-is)
- Other tools: in the next post I’ll use some other tools and platforms… from now I will include Docker, Minikube, and HAProxy
In this lab all of these tools are installed in the following way:
- Vagrant installs Ansible in the remote VM (This is to avoid the Vagrant and Ansible local interaction which is not well supported by Windows host systems).
-
123456789101112131415161718$script = <<-'SCRIPT'if [ ! -d "/vagrant" ]; thenmkdir /vagrantfiif [ ! -d "/ansible" ]; thenmkdir /ansibleapt-get -y update && apt-get -y upgradeapt-get install -y python3 python3-pip python3.10-venvapt-add-repository ppa:ansible/ansible && apt update && apt install -y ansiblefiif [ ! -d "/home/vagrant/.ansible" ];then mkdir /home/vagrant/.ansiblefichown vagrant:vagrant /home/vagrant/.ansibleSCRIPTconfig.vm.provision "shell",inline: $script
-
- Drone, Terraform, and other utilities are provided by playbook files which are uploaded to the remote VM
- Ansible in the remote VM reconciles with the content of the playbook files.
-
1234config.vm.provision "ansible_local" do |ansible|ansible.verbose = "v"ansible.playbook = "ansible_docker.yaml"end
-
Lab up!
To run this lab just clone the repo https://github.com/linoproject/basic_lab_setup and type
1 |
vagrant up |
to build and start the basic lab.
Congratulations! You’ve successfully set up your laboratory environment. If you have any questions, feedback, or suggestions for improvements, feel free to reach out to me on X (@linotelera).
In the upcoming posts, we’ll delve deeper into this lab, exploring various technologies, automation techniques, and enhancements. If you have specific topics you’d like to see covered, or if you have interesting cases to share, don’t hesitate to get in touch.
Enjoy your lab!
Un pensiero riguardo “Lab Time: Setup with Vagrant on VMware Fusion/Workstation”
I commenti sono chiusi.