2.0 KiB
2.0 KiB
Vagrant Installation and Operations Guide (Debian/Ubuntu)
1. Install Vagrant on Debian/Ubuntu
Add the HashiCorp GPG key and repository, then install Vagrant:
wget -O - https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(grep -oP '(?<=UBUNTU_CODENAME=).*' /etc/os-release || lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant
2. Project Setup
Initialize a Vagrant Environment
vagrant init
Initialize with a Specific Base Box
vagrant init ubuntu/focal64
3. Lifecycle Management
Start and Provision the VM
vagrant up
Stop the VM (Graceful Shutdown)
vagrant halt
Force Stop (Power Off)
vagrant halt -f
Reboot the VM
vagrant reload
Reload and Re-Provision
vagrant reload --provision
4. Provisioning
Run Provisioners Without Restarting
vagrant provision
5. Box Operations
List Installed Boxes
vagrant box list
Add a Box
vagrant box add ubuntu/focal64
Remove a Box
vagrant box remove ubuntu/focal64
6. VM Management and Access
SSH into the Machine
vagrant ssh
Get SSH Configuration
vagrant ssh-config
Check VM Status
vagrant status
Show Machine Information
vagrant info
7. Cleanup
Destroy a VM
vagrant destroy
Destroy Without Confirmation
vagrant destroy -f
8. Synced Folder and Debugging
View Global VM List
vagrant global-status
Prune Stale Global Entries
vagrant global-status --prune
Enable Debug Output
vagrant up --debug