Appendix A - Vagrant with VirtualBox within WSL2 to run ansible-for-devops VMs
Author: geerlingguyCreated Jun 24, 2020Updated Mar 9, 2026
I think it may finally work, but there are some caveats.
Following my work on Episode 14 of Ansible 101 (see #289), I found you have to do the following:
- Install WSL2, and install Ubuntu in WSL2.
- Install VirtualBox (I'm running 6.1.x).
- Inside WSL2/Ubuntu/Bash environment, install Vagrant:
a.
wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_linux_amd64.zipb.unzip vagrant_2.2.9_linux_amd64.zipc.sudo mv ./vagrant /usr/local/bin/vagrantd.export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"e.vagrant --version1 cdinto a/mnt/cdirectory (like/mnt/c/Users/jgeerling/Downloads) and clone or otherwise put the ansible-for-devops repository contents in there.cdinto one of the ansible-for-devops example directories (e.g.drupal).- Edit the
Vagrantfileand make sure to disable the default shared folder (add lineconfig.vm.synced_folder '.', '/vagrant', disabled: true).2 - Run
vagrant upfrom that directory.
1 It seems that every time I run a vagrant command, the Bash terminal window is reverted to 'raster' fonts at a very tiny size, and I have to go into the window preferences to revert back to Consolas / 24 pt... Very weird.
2 There's an issue for supporting shared folders within the WSL2 environment here. This might not be needed in the future.
Source: geerlingguy/ansible-for-devops