This page looks best with JavaScript enabled

[My Ansible Journey] Presentation and prerequisites

 ·  ☕ 3 min read  ·  🦆 Jeremy

Part 1 : Presentation and prerequisites
Part 2 : Basics and first Playbook
Part 3 : Variables
––

Updated 01/06/2020 : add venv

I have decided to start a new serie about Ansible. The goal is not to substitute to the official documentation, neither to the how-to you can find on the web, but rather to show you how I use it.

In the next articles, I will mainly use Ansible to automate VMware stuff, but there will be DataCore and Veeam too, and obviously the TIG (Telegraf/InfluxDB/Grafana) stack to monitor all of it.

Ansible is a platform originaly developed by Ansible Inc, which has been rebought by RedHat in 2015. Two main goals here:

  • Automatic deployment
  • Configuration management

Ansible shows up on the market few years after its main competitors (Puppet, Chef, SaltStack…), it gives it an edge over them. The main difference is the absence of an agent, it relies on SSH or WRM instead. The only prerequisite on the managed nodes are Python or PowerShell (depending if you are dealing with Windows Server or Linux based).

WSL

First, I use Ansible with my Windows 10 laptop through WSL (Windows Subsystem for Linux). Ansible must be install on Linux, so WSL allows me not to have to use a dedicated VM.

Why so? Because it’s convenient! I can work on my playboobs with Visual Code, which allows a tight integration with Git.

You can find the official documentation regarding the installatin process here: https://docs.microsoft.com/en-us/windows/wsl/install-win10. Activation of WSL (a reboot is needed):

1
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Download of the desired distribution, Ubuntu 18.04 in my case:

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

Then, installation:

1
Add-AppxPackage .\Ubuntu.appx

Ubuntu 18.04 will be available in the menu:

It will ask for a username and a password:

Then we can upgrade the packages:

1
sudo apt update && sudo apt upgrade

VirtualEnv

Ansible shows up on the market few years after its main competitors (Puppet, Chef, SaltStack…), it gives it sort of an edge over them. The main difference is the absence of an agent, it relies on SSH or WRM instead. The only prerequisite on the managed nodes are Python or PowerShell (depending if you are dealing with Windows Server or Linux based).
VirtualEnv allows you, inside of a folder, to have the Python binaries alongside of needed the libraries for a given project. In our example, it bring some advantages:

  • To be able to use an up-to-date version of Ansible (installed through Python Pip)
  • Allowing us to install specific libraries (also through Pip)

VirtualEnv installation:

1
sudo apt-get install virtualenv

Creation of a venv with Python3 which we will name ansible:

1
virtualenv -p /usr/bin/python3 ansible

venv activation:

1
source ansible/bin/activate

We can see the ansible which tell us we have inside of the venv. To exit, just type deactivate

Ansible installation

Installation through Pip:

1
pip install ansible

We check the Ansible and Python version in use:

1
ansible --version

Visual Code

I use Visual Code as my main IDE. It is a great product with, very popular these days. There are a lot of plugins available.

It is a good start to begin with Ansible on WSL, to be continued!

Share on