Installing Linux under WSL

If you have a recent enough build of Windows 10, then installing your preferred Linux is as easy as opening the Microsoft Store and searching for it. For example, search for Ubuntu and you should find it easily. This is displayed in the following screenshot:

Click on the Get button and wait for the installation to complete. If you are running Windows 10, but a build earlier than 16215, or indeed Windows Server 2019, then the installation of Linux is a slightly more manual process. First of all, download your preferred Linux distribution from Microsoftfor example, Ubuntu can be downloaded using the following PowerShell command:

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1804 -OutFile Ubuntu.appx -UseBasicParsing

Once successfully downloaded, unzip the Ubuntu.appx filethis can be unzipped to any location provided that it is on the system (boot) drive, normally C:. If you want to keep your Linux distribution private, it can be unzipped somewhere within your profile directory, otherwise you can unzip the file anywhere on the system drive. For example, the following PowerShell commands would unzip the archive into C:\WSL\:

Rename-Item Ubuntu.appx Ubuntu.zip 
Expand-Archive Ubuntu.zip C:\WSL\Ubuntu

Once completed, you can launch your newly-installed Linux distribution using the executable named after the distribution itself. In the case of our Ubuntu example, you would run the following:

C:\WSL\Ubuntu\ubuntu.exe

The first time you run your newly installed Linux distribution, whether it was installed through the Microsoft Store or installed manually, it will initialize itself. As part of this process, it will ask you to create a new user account. Please note that this account is independent of your Windows username and password, so be sure to remember the password you set here! You will need it every time you run commands through sudo (for example), although, as with any Linux distribution, you can customize this behavior through /etc/sudoers if you wish. This is demonstrated in the following screenshot:

Congratulations! You now have Linux running under WSL. From here, you should follow the standard installation process for Ansible, and you can run it from your Linux subsystem just as you would on any other Linux box.