Objective

The following guide describes simple to follow steps on how to install the open-source automation engine Ansible on CentOS Linux.

Operating System and Software Versions

  • Operating System: - CentOS 7 Linux
  • Software: - Ansible 2.2 ( EPEL ) & Ansible 2.4 ( Source )

Requirements

Privileged access to your CentOS Linux system will be required to perform the Ansible installation.

Difficulty

MEDIUM

Conventions

  • # - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
  • $ - requires given linux commands to be executed as a regular non-privileged user

Instructions

Installation from EPEL repository

The easiest way to perform the Ansible installation on CentOS Linux is by using standard package repository and EPEL repository. The disadvantage is that most likely you will install outdated but stable Ansible version. First install enable EPEL repository by install the following package:
# yum install epel-release
Next, install ansible:
# yum install ansible
If installed correctly you should be able to use the ansible command to query its version number:
$ ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

SUBSCRIBE TO NEWSLETTER
Subscribe to Linux Career NEWSLETTER and receive latest Linux news, jobs, career advice and tutorials.


Installation from Source

The following paragraph describes the Ansible installation from source. Let's start by installation of all required prerequisites to perform Ansible compilation:
# yum install make git make gcc python-devel libffi-devel openssl-devel epel-release python-sphinx
Next, install python package manager:
# yum install python-pip 
At this stage we are ready to download the Ansible source code using git command:
$ git clone git://github.com/ansible/ansible.git
$ cd ansible
Optionally, selected your desired Ansible version using git checkout command. If no Ansible version is selected, you will be installing the latest Ansible version available. While in ansible directory, first list all available stable versions:
 $ git branch -a | grep stable
  remotes/origin/stable-1.9
  remotes/origin/stable-2.0
  remotes/origin/stable-2.0-network
  remotes/origin/stable-2.0.0.1
  remotes/origin/stable-2.1
  remotes/origin/stable-2.2
  remotes/origin/stable-2.3
Select desired version eg.:
$ git checkout stable-2.3
If all went well, now we are ready to perform the Ansible compilation and installation:



NOTE: Most likely the below compilation will be interrupted due to the outdated setuptools and pip versions. Refer to the appendix below on how to resolve this issues.
$ make
# make install
Test ansible installation by retrieving its version number:
$ ansible --version
ansible 2.4.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]

Appendix

error: Installed distribution setuptools 0.9.8 conflicts with requirement setuptools>=11.3
Update your setuptools using the below command:
# pip install --upgrade setuptools

You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
As suggested above, run the following linux command to update python package manager:
# pip install --upgrade pip
FIND LATEST LINUX JOBS on LinuxCareers.com
Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
LINUX CAREER NEWSLETTER
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
DO YOU NEED ADDITIONAL HELP?
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: