Install Vagrant
Categories:
2 minute read
If you intend to use Vagrant alongside for example VirtualBox and Ansible on Windows you will need to run things in the WSL. This requires a specific configuration and is not just download the installer and click next.
The WSL distro used here is Ubuntu 20.04
Vagrant installation
You require Vagrant to be installed on both Windows and the WSL instance. They must be the same version.
Install Vagrant onto Windows
Find the downloader for your Windows on the Vagrant site and install it.
You will probably need to reboot
Install Vagrant onto WSL Logon to the WSL instance and run the following
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
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
sudo apt update && sudo apt install vagrant
Check the installed version The command is the same for each OS. Check they match and adjust as needed.
vagrant --version
WSL configuration
On the WSL instance you need to configure some environment variables that allows Vagrant to function between Windows and WSL.
On the WSL instance edit the startup script.
vi ~/.bashrc
At these lines to the end of the file.
Replace
username
in the path with your username
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/username/"
export PATH="$PATH:/mnt/d/Programs/Virtualbox"