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:

  1. Install WSL2, and install Ubuntu in WSL2.
  2. Install VirtualBox (I'm running 6.1.x).
  3. Inside WSL2/Ubuntu/Bash environment, install Vagrant: a. wget https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_linux_amd64.zip b. unzip vagrant_2.2.9_linux_amd64.zip c. sudo mv ./vagrant /usr/local/bin/vagrant d. export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1" e. vagrant --version1
  4. cd into a /mnt/c directory (like /mnt/c/Users/jgeerling/Downloads) and clone or otherwise put the ansible-for-devops repository contents in there.
  5. cd into one of the ansible-for-devops example directories (e.g. drupal).
  6. Edit the Vagrantfile and make sure to disable the default shared folder (add line config.vm.synced_folder '.', '/vagrant', disabled: true).2
  7. Run vagrant up from 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