Welcome to the Ansible video training for network engineers, especially Cisco network engineers. In the last video we saw the real application of Ansible in monitoring and troubleshooting. Hope you get a good feel for Ansible when you can monitor and manage many devices at the same time. In this part we are going to install the latest version of ansible on Debian machine (debian install ansible).

I chose Debian, but there isn’t much of a difference if you choose a different distribution.

access ansible codes of this course in github

Ansible Installation process on Debian in Ansible website

When we search for “install ansible” in Google. The links to docs.ansible.com will direct you to the installation guide for the latest version of ansible.

this is a video-based training therefore the output of running commands are not show in the text.

The prerequisites part says that Ansible requires Python2 or Python3. Which is installed by default in Debian machine for me. It is also said that many operating systems are supported as control nodes. This includes Red Hat, Debian, CentOS, macOS, all BSDs etc, but Windows is not supported for the control node.

In the part “Installing Ansible on Debian”,  shows how to Install Ansible in Debian machine.

First we have to update the repository source.

# deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main

! See the output of all commands in this document in the video

then we use apt-key  to update the list of keys used by apt to authenticate packages.

# sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367

The apt-key command requires gnupg to be installed on your computer, which for me is not installed by default. So I need to add it before using the apt-key command.

Then we can easily Install Ansible with apt package manager.

Now start the installation of Ansible on Debian version 10.

Let’s check the version of my Debian first. I didn’t install anything other than system utilities and SSH in the Debian installation process.

# lsb_release -a

as you can see it is Debian 10.

Then we make sure that Python is already installed on our computer.

# python --version
# python3 –version

As you can see, both Python version 2 and version 3 are installed by default.

Let’s now follow the installation process as explained earlier.

Add the following line to /etc/apt/sources.list:

# deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main
# apt-get install gnupg
# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
# apt update
# apt install ansible

Now we can check which version of Ansible is installed on our computer and based on which version of Python.

root@debian:~# ansible --version

As you can see, the installed version of Ansible is 2.9.21 and is based on Python 2.

Most likely this is enough to work with ansible. However, if you install ansible based on Python 3, you will get the higher version of ansible with updated modules. There are some modules or some options in modules that only work with newer versions of ansible.

In general it is recommended to install ansible based on Python3 in order to get most of the functions of ansible. To do this, we uninstall the currently installed Ansible and replace it with Ansible based on Python3.

With apt remove we can remove the installed version of ansible.

# apt remove ansible

I want to install a newer version of ansible using the Python3 package manager (pip3). So I install pip3 first and then ansible over pip3.

# apt install python3-pip

To make sure pip3 is installed we use pip3 –version

# pip3 --version

Then wen install ansible with pip3

# pip3 install ansible

If we use ansible –version after successful installation, it cannot find ansible in our system.

# ansible --version

We use the find command to find ansible’s new location.

# find / -name ansible | grep bin

As you can see, it’s located in /usr/local/bin/ folder

Now we run the ansible command to see the version of the installed ansible.

# /usr/local/bin/ansible –version

As you can see, the version is 2.10.9 and is also based on Python 3, which is newer than 2.9.21 which was based on Python2.

I will add ansible executable folder to the system PATH directory. So we don’t have to switch to this folder every time.

# PATH=$PATH:/usr/local/bin/
# Ansible --version

To permanently add this path to the system PATH, we will update the .bashrc file.

# nano ~/.bashrc
# export PATH="$PATH:/home/$USER/.local/bin"
# source ~/.bashrc
# env | grep PATH

Now we can begin basic Ansible configuration but in the next video.

Back to: Ansible for Network Engineers > basic Configurations and adhoc Commands

Leave a Reply

Your email address will not be published. Required fields are marked *


Post comment