Ansible on WSL

Ansible on WSL

Ansible is a powerful open source automation language. It’s also a complete deployment and orchestration tool. It provides drop-in replacements for many core capabilities in other automation solutions, whilst also seeking to solve IT challenges, such as CI/CD. Ansible is an agentless automation tool that by default manages machines over the SSH protocol or WinRM on Windows. Ansible can be installed on many Linux distros however it can't be installed directly on Windows.

I often find it useful to have Ansible installed on your development machine for simple commands like encrypting / decrypting password in ansible-vault. This is where the Windows Subsystem for Linux comes in handy.

Installing and Configuring WSL and WSL Interop

In a previous post we documented the installing and configuration of WSL and the WSLInterop PowerShell module. Please follow these instructions if you dont already have them installed:

Installing Ansible on WSL 2 Ubuntu

Launch Ubuntu and in the terminal run the following commands:

    sudo apt update
    sudo apt upgrade
    sudo apt install -y python3-pip
    python3 -m pip update pip
    sudo python3 -m pip install git+https://github.com/ansible/ansible.git@v2.17.0
Configuring WSL Interop

Open your powershell profile

    code $profile

Add the following lines

    Import-WslCommand ansible-vault
    Import-WslCommand ansible
About the author:
Mark Pollard

Mark Pollard

I am a senior software engineering and technical leader / Microsoft technologies technical architect, with a strong passion for continuous delivery. I am a firm believer in empowered teams with true DevOps cultures. I encourage responsibility over role, high quality and full stack engineers, showing ownership of the software and its behaviour, end to end, from requirements maturing all the way through to its continual and successful running in Production.