How to Install and Configure ‘Ansible’ Automation Tool for IT Management – Part 1

Ansible is an open source, powerful automation software for configuring, managing and deploying software applications on the nodes without any downtime just by using SSH. Today, most of the IT Automation tools runs as a agent in remote host, but ansible just need a SSH connection and Python (2.4 or later) to be installed on the remote nodes to perform it’s action.

Install Ansible in Linux
Install Ansible in Linux

How Ansible Works?

There are many similar automation tools available like Puppet, Capistrano, Chef, Salt, Space Walk etc, but Ansible categorize into two types of server: controlling machines and nodes.

The controlling machine, where Ansible is installed and Nodes are managed by this controlling machine over SSH. The location of nodes are specified by controlling machine through its inventory.

The controlling machine (Ansible) deploys modules to nodes using SSH protocol and these modules are stored temporarily on remote nodes and communicate with the Ansible machine through a JSON connection over the standard output.

Ansible is agent-less, that means no need of any agent installation on remote nodes, so it means there are no any background daemons or programs are executing for Ansible, when it’s not managing any nodes.

Ansible can handle 100’s of nodes from a single system over SSH connection and the entire operation can be handled and executed by one single command ‘ansible’. But, in some cases, where you required to execute multiple commands for a deployment, here we can build playbooks.

Playbooks are bunch of commands which can perform multiple tasks and each playbooks are in YAML file format.

What’s the Use of Ansible

Ansible can be used in IT infrastructure to manage and deploy software applications to remote nodes. For example, let’s say you need to deploy a single software or multiple software to 100’s of nodes by a single command, here ansible comes into picture, with the help of Ansible you can deploy as many as applications to many nodes with one single command, but you must have a little programming knowledge for understanding the ansible scripts.

We’ve compiled a series on Ansible, title ‘Preparation for the Deployment of your IT Infrastructure with Ansible IT Automation Tool‘, through parts 1-4 and covers the following topics.

Part 1: How to Install and Configure Ansible for IT Management in Linux
Part 4: Managing Encrypted YAMAL data with Ansible-Vault

In this article, we will show you how to install ‘Ansible’ on RHEL/CentOS 7/6, Fedora 21-19, Ubuntu 14.10-13.04 and Debian 7/6 systems and also we will go through some basics on how how to manage a server by installing packages, applying updates and much more from basic to pro.


  1. Operating System: RHEL/CentOS/Fedora and Ubuntu/Debian/Linux Mint
  2. Jinja2: A modern, fast and easy to use stand-alone template engine for Python.
  3. PyYAML: A YAML parser and emitter for the Python programming language.
  4. parmiko: A native Python SSHv2 channel library.
  5. httplib2: A comprehensive HTTP client library.
  6. sshpass: A non-interactive ssh password authentication.

My Environment Setup

Controlling Machine – Ansible
Operating System :	Linux Mint 17.1 Rebecca
IP Address	 :
Host-name	 :
User		 :	tecmint
Remote Nodes
Node 1:
Node 2:
Node 3:

Step 1: Installing Controlling Machine – Ansible

1. Before installing ‘Ansible‘ on the server, let’s first verify the details of the server like hostname and IP Address. Login into server as a root user and execute the below command to confirm system settings that we’re going to use for this setup.

# sudo ifconfig | grep inet
Verify System Details
Verify System Details

2. Once you confirm your system settings, it’s time to install ‘Ansible’ software on the system.

On Ubuntu/Debian/Linux Mint

Here we are going to use official Ansible PPA repository on the system, just run the below commands to add the repository.

$ sudo apt-add-repository ppa:ansible/ansible -y
$ sudo apt-get update && sudo apt-get install ansible -y
Add Ansible PPA
Add Ansible PPA
Install Ansible in Ubuntu
Install Ansible in Ubuntu
On RHEL/CentOS/Fedora

Unfortunately, there are no official Ansible repository for RedHat based clones, but we can install Ansible by enabling epel repository under RHEL/CentOS 6, 7 and currently supported fedora distributions.

Fedora users can directly install Ansible through default repository, but if you are using RHEL/CentOS 6, 7, you have to enable EPEL repo.

After configuring epel repository, you can install Ansible using following command.

$ sudo yum install ansible -y

After installed successfully, you can verify the version by executing below command.

# ansible --version
Verify Ansible Version
Verify Ansible Version

Step 2: Preparing SSH Keys to Remote Hosts

4. To perform any deployment or management from the localhost to remote host first we need to create and copy the ssh keys to the remote host. In every remote host there will be a user account tecmint (in your case may be different user).

First let we create a SSH key using below command and copy the key to remote hosts.

# ssh-keygen -t rsa -b 4096 -C "[email protected]"
Create SSH Key
Create SSH Key

5. After creating SSH Key successfully, now copy the created key to all three remote server’s.

# ssh-copy-id [email protected]
# ssh-copy-id [email protected]
# ssh-copy-id [email protected]
Copy SSH Key Remote Server
Copy SSH Key Remote Server
Copy SSH Key Second Remote Host
Copy SSH Key Second Remote Host

6. After copying all SSH Keys to remote host, now perform a ssh key authentication on all remote hosts to check whether authentication working or not.

$ ssh [email protected]
$ ssh [email protected]
$ ssh [email protected]
SSH Key Authentication
SSH Key Authentication
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

51 thoughts on “How to Install and Configure ‘Ansible’ Automation Tool for IT Management – Part 1”

  1. Hi, I am getting below error when I try to install ansible on Linux.

    Error: Package: python-paramiko-2.1.1-0.4.el7.noarch (epel)
               Requires: python2-pyasn1
    Error: Package: python-paramiko-2.1.1-0.4.el7.noarch (epel)
               Requires: python-cryptography

    Can someone please help..

  2. Error: Package: ansible- (epel)
    Requires: python-jinja2

    Ansible installation issue
    Error: Package: python-paramiko-2.1.1-0.2.el7.noarch (epel)
    Requires: python-cryptography
    You could try using –skip-broken to work around the problem
    You could try running: rpm -Va –nofiles –nodigest

    when I have tried to install the ansible, after enable the repo also I am getting the following error

    • @Manikandan,

      I think you first install python-cryptography manually using PIP tool as shown.

      $ sudo pip install pycrypto
  3. Faced some issues while installing Ansible in linux. Got resolved by installing below packages.

    error: Failed dependencies:
    python-httplib2 is needed by ansible-
    python-jinja2-26 is needed by ansible-
    python-keyczar is needed by ansible-
    python-setuptools is needed by ansible-
    python-six is needed by ansible-
    sshpass is needed by ansible-

    Downloaded separately all the rpms from and installed.

  4. Issue got resolved by below command after keygen in host1


    then run the ansible
    ansible -m command -a “df -h ” webservers

  5. I was not able to install ansible in my REDHAT 7, after running the below commands;

    $ sudo yum install ansible -y
    $ wget
    $ sudo rpm -ivh epel-release-7-10.noarch.rpm

    Return output

    Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
    epel/x86_64/metalink                                                                                                                                                                      |  18 kB  00:00:00
    epel                                                                                                                                                                                      | 4.3 kB  00:00:00
    (1/3): epel/x86_64/group_gz                                                                                                                                                               | 170 kB  00:00:00
    (2/3): epel/x86_64/updateinfo                                                                                                                                                             | 840 kB  00:00:00
    (3/3): epel/x86_64/primary_db                                                                                                                                                             | 4.8 MB  00:00:00
    No package ansible available.
  6. Hello Team,

    On Production server, We can’t provide internet access to server. I have download ansible.tar file. Can you suggest me the steps to install ?

    Rajesh kathar

  7. | UNREACHABLE! => {
    “changed”: false,
    “msg”: “Failed to connect to the host via ssh: Permission denied (publickey,password).\r\n”,
    “unreachable”: true
    } | UNREACHABLE! => {
    “changed”: false,
    “msg”: “Failed to connect to the host via ssh: ssh: connect to host port 22: Connection timed out\r\n”,
    “unreachable”: true

    • I got the same error. I fixed it by
      1) installing python on remote servers
      2) Adding the following line to /etc/ansible/hosts ( my user is shivaji )

    • my be your network (server )is not reachable or you havent copy ssh-key for password less login or defined user havent any key to that server.


Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.