Vagrant
Vagrant is a tool for building complete development environments, sandboxed in a virtual machine. Vagrant lowers development environment setup time, increases development/production parity, and brings the idea of disposable compute resources down to the desktop.
Installation
Vagrant can be installed on Arch as shown below:
pacman -S vagrant
Moreover, we need to install a vm provider, such as virtualbox, to be able to run a vm on the system:
pacman -S virtualbox virtualbox-host-modules
Basic CLI
Command | Description |
---|---|
vargrant -h | Show help. |
vagrant init | Create Vagrantfile in current working directory. |
vagrant up | Starts and provisions the vagrant environment. |
vagrant ssh | SSH into the VM. |
vagrant global-status | Outputs status Vagrant environments for this user. |
vagrant status | Outputs status of the vagrant machine. |
vagrant package | Packages a running vagrant environment into a box. |
vagranr reload | Restarts vagrant machine, loads new Vagrantfile configuration. |
vagrant resume | Resume a suspended vagrant machine. |
vagtant halt | Stops the vagrant machine. |
vagrant snapshot | Manages snapshots: saving, restoring, etc. |
vagrant suspend | Suspend the virtual machine. |
vagrant destroy | Stops and deletes the virtual machine. |
vagrant box | Manages boxes: installation, removal, etc. |
Basic Workflow
- Git clone project with a Vagrantfile
- cd into project dir
- Run vagrant up to start the vm
- Do some stuff
- Stop the vm
git clone https://github.com/pro-vagrant/songs-app-django.git
cd songs-app-django.git
vagrant up
To check the status, we can simply run:
vagrant status
Alternatively, we can also use the global-status
command to get an overview
of all running vms on the system:
vagrant global-status
We can also ssh into the vm:
vagrant ssh
For stopping the vm we can run the halt
command:
vagrant halt
Examples
Create a new Ubuntu Artful VM
vagrant init ubuntu/artful64
Create a new Ubuntu Bionic VM
vagrant init ubuntu/bionic64
Running the VM
vagrant up
SHH into the VM
vagrant ssh
Stopping the VM
vagrant halt