Using Ansible on RedHat / CentOS 7
Ansible is a great tool for automation and orchestration and is getting a lot of attention. However it can sometimes be challenging to get the latest version working on your environment. This blog covers how to install the latest version of Ansible on RedHat Enterprise Linux or CentOS 7 environment.
About RedHat/CentOS and Yum
RedHat and CentOS have a great version control over the software versions that are distributed with each OS release. This provides reliability and compatibility through updates and upgrades. However sometimes this can make our life a bit difficult, if we want to defer from the default version and move to a later version of the software.
By default RedHat and CentOS uses Yum as a software package manager to install software. Just a side step, Yum stands for Yellowdog Updater, Modified. Totally besides the point, but even though I’ve been using Yum for quite some years now, I didn’t actually know the acronym before writing this blog.
Anyways, by default Yum will install Ansible version 2.9 on CentOS7, which is quite recent, however it still uses Python2 as a requirement. Formal support for Python2 ended in Jan 2020 so you could run into issues around support. Also the current latest version of Ansible, version 2.10 is not available.
Installing Ansible 2.10 using Python3
In the next few steps, we’ll install Python3 and use the Package Installer for Python (pip). We’ll the use pip to install the lastest version of Ansible on RedHat / CentOS.
The first step is to remove any default installation of Ansible from our system. We’ll use the rpm command to remove the default Ansible package (if it was installed).
sudo rpm -e ansible
Next we want to install Python3 and the Package Installer for Python (pip), which we’ll use to install Ansible. So here we use Yum to install this.
sudo yum install python3-pip
Next we will upgrade our Package Installer for Python (pip) and use pip3 to install Ansible.
pip3 install --upgrade pip pip3 install ansible
And that’s it. We now have the latest version of Ansible running on our system, backed by Python3. So get ready to make some awesome Ansible playbooks.