WSL and Ansible

WSL and Ansible

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.

The Windows Subsystem for Linux (WSL) is a compatibility layer for running GNU/Linux binary executables natively on Windows 10 and Windows Server 2019. It supports running most command-line tools, utilities, and applications unmodified, without the overhead of a traditional virtual machine or dualboot setup You can install many GNU/Linux distributions ontop of the subsystem kernel. In this article we will be using Ubuntu.

I often find it useful to have Ansible installed on your development machine for simple commands like encrypting / decrypting password in ansible-vault.

Installing/Enabling WSL and Ubunti

First enable the Sub System through the Windows Features settings

Enable Windows Feature
Enable WSL

Then install ubuntu from the Microsoft Store

Install Ubuntu
Launch Ubuntu and configure your user details. 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.10.4

WSL Interop

Its useful to expose some of the commands such as ansible-vault to the Powershell console in Windows. This saves you the time switching between shells.
Open a Powershell windows and run the following
    Install-Module WslInterop
Then open your powershell profile
    notepad $profile
Add the following lines
    Import-WslCommand ansible-vault
    Import-WslCommand ansible
    Import-WslCommand ssh
    Import-WslCommand grep

Share:

Image Description

Mark Pollard

I am a technical, delivery and engineering leader / Microsoft technologies technical architect, with a strong passion for software engineering. 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 through to its continual and successful running in Production.

All author posts

About

Code Build deploy is a reference site on topics I have found useful, inspired by continuous delivery approaches

Monthly Newsletter

Subscribe to our newsletter and stay up to date with the latest news from mark pollard web!

 

Recent Blog Entries



Contact

Bradford,
West Yorkshire,
United Kingdom

(+44)7912359944