Linux Subsystem on Windows 10: Python and Ansible

Last week, using a couple of sets of instructions, I installed the Linux Subsystem on Windows 10. You can find the instructions at https://www.jeffgeerling.com/blog/2017/using-ansible-through-windows-10s-subsystem-linux#comment-6341 and https://msdn.microsoft.com/en-au/commandline/wsl/install_guide.

Since then, I haven’t had much of a chance to play with it. However, I’ve been meaning to use Python more often in my daily work, so I thought it would be fun to write a Python script and run it in “Bash on Ubuntu on Windows”.

But first… I wanted to set up my development environment in a way that would be easy to keep track of. I think it’s really easy to get ahead of ourselves sometimes and just start downloading a million packages using a few different package managers and then we wind up with a system full of stuff that we don’t actually use. Of course, virtual environments and the like can get you around that a bit at a language level, but I like documentation… and I really like Ansible.

Unlike Jeff Geerling in the above instructions, I just ran “apt-get install ansible” to install Ansible via “Bash on Ubuntu on Windows”. I’m not too fussed about getting the most recent version, so the version in Ubuntu’s Xenial repositories from January 2016 (ie 2.0.0.2) suits me fine for experimenting at this point.

At this point, I’ve been using Ansible for years, so I put together a quick little playbook to install the package “python3-mysqldb” and that ran successfully. While Ansible itself uses python2, “Bash on Ubuntu on Windows” comes with python3 out of the box. I’ve used python2 a bit over the years, both for developing Ansible modules and for other Python scripts, but I thought I’d try something new. Plus, if I’m going to be using Python more and more, I may as well use the current version rather than the legacy version of Python.

I don’t have much else to say at this point. If I keep experimenting with “Bash on Ubuntu on Windows”, I’ll make more follow-up posts. Honestly, I should be doing more work directly on Windows, as I want to learn more about that, since I’m already familiar with Linux servers and Linux desktops/laptops from my personal and professional life. But… being able to use Linux from within Windows seems so convenient! Of course, I could be running Python on Windows directly, but Windows often seems like an unpleasant place to work. It feels like it’s more difficult to keep track of things there. But maybe that’s just due to my unfamiliarity with working on Windows as a developer. Maybe I’ll write some Python tools and run them from Windows and from Ubuntu on Windows and see if I can get used to using Windows as a developer…