Vagrant
Build and manage reproducible virtual machine environments
Description
Vagrant is a tool for building and managing virtual machine environments in a single workflow. It provides easy-to-configure, reproducible, and portable work environments using providers like VirtualBox, VMware, and Docker. Vagrant lowers development environment setup time and increases production parity.
Install
brew install vagrantAI Summary
Tool for building, configuring, and managing reproducible virtual machine environments using a simple declarative Vagrantfile with support for VirtualBox, VMware, Docker, and other providers.
Capabilities
- + Create and configure virtual machines from a Vagrantfile
- + Provision VMs with shell scripts, Ansible, Chef, or Puppet
- + Share and distribute pre-built VM images (boxes)
- + Sync folders between host and guest machines
- + Configure networking, forwarded ports, and multi-machine setups
- + Support multiple providers including VirtualBox, VMware, and Docker
Use When
- → Setting up reproducible development environments across a team
- → Need isolated virtual machines for testing or development
- → Building multi-machine environments that mirror production
- → Want declarative VM configuration checked into version control
Avoid When
- x Working with containers (use Docker or Podman instead)
- x Need lightweight ephemeral environments without full VMs
- x Running on machines without virtualization support
Usage Patterns
Initialize and start a VM
vagrant init ubuntu/jammy64 && vagrant up Creates a Vagrantfile with Ubuntu 22.04 and boots the VM
SSH into a running VM
vagrant ssh Opens an SSH session to the default machine
Destroy and recreate from scratch
vagrant destroy -f && vagrant up Tears down the VM and provisions a fresh one
Take and restore a snapshot
vagrant snapshot save clean-state Saves the current VM state for later restoration
Input / Output
Typical Pipelines
vagrant up && vagrant ssh -c 'run-tests.sh' to boot a VM and run tests vagrant status | grep running to check which machines are active vagrant snapshot save before-update && vagrant provision to safely re-provision