Some years ago Microsoft announced the Windows Subsystem for Linux (WSL), which gave Windows 10 users the ability to run a Linux distro directly from their Windows install without the need for a VM.
I remember being somewhat dismissive and thinking to myself “why would anybody want to do that”. Fast forward a few years, and after spending many hours trying to get various Python packages to run under Windows, and having to deploy and maintain VMs to run tools like Ansible, I’ve seen the light.
This is a quick start no frills guide to getting Ubuntu installed and running, along with Ansible, on WSL.
Windows Subsystem for Linuxunder
Turn Windows features on or offin the Control Panel
- Reboot (I love you, Windows)
- Open the Microsoft Store, find and install Ubuntu
- Find Ubuntu in the Start Menu, and run it
You will now find yourself in a bash shell running Ubuntu.
We can then do the usual update and upgrade
sudo apt-get update && sudo apt-get upgrade
Installing Python and Ansible
Finally we need to install the pre-reqs and Ansible itself.
sudo apt-get -y install python-pip python-dev libffi-dev libssl-dev
pip install ansible --user
This will install Ansible in the users context (This is done to avoid permission issues with Pip that are specific to WSL)
Finally we update the $PATH to include
~/.local/bin where Ansible will live.
echo 'PATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
That should be it, we now have a working Ansible install without the need to run a VM!
[email protected]:~$ ansible --version ansible 2.8.0 config file = None configured module search path = [u'/home/md/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /home/md/.local/lib/python2.7/site-packages/ansible executable location = /home/md/.local/bin/ansible python version = 2.7.15rc1 (default, Nov 12 2018, 14:31:15) [GCC 7.3.0]