~/CloudSetup.In

Vagrant

Infrastructure Vagrantfile ● stable

Spin up reproducible development VMs from a single declarative file.

01 Overview

Vagrant scripts the creation of local virtual machines against a chosen provider (VirtualBox, libvirt, Docker) so a whole team can boot the same disposable dev environment with one command.

→ official documentation

02 Installation

Pick a platform. Each step is copy-pasteable on its own.

01  Install prerequisites
sudo apt-get update && sudo apt-get install -y gnupg software-properties-common curl
02  Add the HashiCorp GPG key and repo
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
03  Install Vagrant
sudo apt-get update && sudo apt-get install -y vagrant
04  Verify
vagrant --version
01  Add the HashiCorp repo
sudo dnf install -y dnf-plugins-core
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
02  Install Vagrant
sudo dnf install -y vagrant
03  Verify
vagrant --version
01  Install via Homebrew
brew install --cask vagrant
02  Verify
vagrant --version
Note — commands assume sudo privileges and an up-to-date package index. Pin a specific version in production rather than tracking latest.

03 Install script

The steps above bundled into a single idempotent shell script for provisioning boxes unattended.

install-vagrant.sh
Ubuntu/Debian target · safe to re-run · exits non-zero on failure
↓ download script

04 Cheatsheet

The commands reached for most often once Vagrant is installed.

CommandWhat it does
vagrant init hashicorp/bionic64Create a Vagrantfile for a base box
vagrant upCreate and boot the VM
vagrant sshSSH into the running VM
vagrant haltStop the VM
vagrant destroyDelete the VM entirely
vagrant statusShow current VM state
vagrant provisionRe-run provisioning scripts on a running VM