Would appreciate help in using Vagrant and Ansible to spin-up and provision virtual servers managed by Hyper-V on Windows 11. Currently, I have the latest version of Vagrant (2.4.0) installed on both Windows 11 and in WSL2 (Ubuntu). Ansible is installed on Ubuntu in WSL2.
My assumption is to run Vagrant and Ansible within Ubuntu. I've tried to run vagrant up but found I had to run as admin using sudo vagrant up. I'm currently receiving this error message when running within Ubuntu:
Vagrant failed to initialize at a very early stage:
The executable 'cmd.exe' Vagrant is trying to run was not found in the PATH variable. This is an error. Please verify this software is installed and on the path.
After reading a number of blog posts and Vagrant documentation files, I've modified my ~/.zshrc file to include:
export PATH=$PATH:/mnt/c/windows/system32
export PATH=$PATH:/mnt/c/ProgramData/Microsoft/Windows/Hyper-V
export PATH=$PATH:/mnt/c/Windows/System32/WindowsPowerShell/v1.0
export VAGRANT_WSL_WINDOWS_ACCESS_USER_HOME_PATH="/mnt/c/Users/<my username>/"
export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS="1"
export VAGRANT_DEFAULT_PROVIDER=hyperv
I've also verified that Ubuntu is running the the vagrant installation within Ubuntu and not Windows via which vagrant returns: /usr/bin/vagrant.
If I type cmd.exe within Ubuntu, it does execute windows command shell. I'm assuming the problem is still with access rights for vagrant.