HomeAutomation Tools

Ansible Installation and Configuration on Redhat/CentOS 7

Ansible Installation and Configuration on Redhat/CentOS 7
Like Tweet Pin it Share Share Email
1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

Ansible is an IT automation tool and it can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
Ansible manages machines in an agentless manner. Ansible uses OpenSSH for transport and it is decentralized, that means it relies on your existing OS credentials to control access to remote machines; if needed it can easily connect with
Kerberos, LDAP, and other centralized authentication management systems.How to Install and Configuration of Ansible IT Automation Tool on Linux.

In this step by step guide, you are going to learn how to get started with IT Automation with Ansible. This is your first step to understand the basic functionality of Ansible and how to Install/Configure Ansible IT Automation Tool on Enterprise Linux (RHEL/CentOS 7).  You will also learn how to get Ansible installed with different methods and some basic concepts. you’ll learn how to execute ad-hoc commands from the master node to done some simple tasks across your nodes using Ansible command (/usr/bin/ansible). you’ll also see what sort of modules are available in Ansible’s core (though you can also write your own, which we’ll also show later). So let’s get start with your first question.

1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

What is Ansible?

Ansible is an open-source automation engine that automates software provisioning, configuration management, and application deployment. Ansible can manage any *NIX platform through the SSH and also Ansible can manage Windows Servers and Network devices.

Ansible is the only Automation Engine that can automate the entire application lifecycle and Continues Delivery pipeline.

  • Ansible is Simple to install and configure and it Can manage almost any *IX through SSH
  • Ansible Requires Python 2.4 for Installation
  • Windows (PowerShell, WinRM python module)

Feature and Benefits of Ansible

  • Cross platform support – can support any *NIX, Windows machines, network devices etc.
  • Agentless Architecture, and minimal setup on Master node. so no work for system admins to manage the agent’s on the client side
  • Written in Python.
  • Ansible uses OpenSSH for *NIX systems and WinRM for communication with MS Windows machines.
  • Open source and activity maintained on the GitHub.
  • Very easy install and configure.
  • Highly scalable – Can manage Thousands of nodes
  • Secure as it used SSH for the communication.
  • Easy to understand and remember the command syntax. (No coding skills needed). Ansible uses simple declarative language YAML

Ansible is not just automation engine, but it is also used for:

  • Configuration Management.
  • Application Deployment.
  • Orchestrations
  • Security and Compliance
  • Rolling Upgrades – Continue Deployment (CD)
  • Provisioning (AWS, Virtual Platform, OpenStack etc…)

Key Components of Ansible

  • Ansible Modules.
  • Inventory.
  • Tasks.
  • Variables.
  • Playbooks

Further to the playbooks, Ansible roles can be configured for the more systematic management of the Ansible playbooks.

Step 1: Ansible Installation on Red Hat / CentOS 7:  You can install Ansible control machine with many different methods. In this guide, I am going to show you Ansible installation using Python-PIP and EPEL Repository (YUM).

Ansible Master Node details:


Ansible Master Node Host file: Remote host details


Method -1: Ansible Latest Release Installation Via Pip
Ansible can be installed via “pip”, the Python package manager. If ‘pip’ isn’t already available in your version of
Python, you can get pip install by running the below command.



Ansible also uses the following Python modules that need to be installed:

After installation of all pre-requisites and python-pip, then install Ansible with the below command.

The below command will Ansible latest release from Python Package Manager:


Method -2: Ansible Latest available Release installation Via Yum
RPMs are available from yum for EPEL 6, 7, and currently supported Fedora distributions. Ansible itself can manage earlier operating systems that contain Python 2.4 or higher. Fedora users can install Ansible directly, though if you are using RHEL or CentOS and have not already done so,
First configure EPEL Repository on Linux, because Ansible packages are available from EPEL. install the epel-release RPM if needed on CentOS, RHEL, or Scientific Linux

Now run the below command to install Ansible along with all dependencies.


Step 2: Ansible Installation Verification:  Just executes the ansible –version command to check Ansible available status in your Master node. Checking the Ansible Version and Config Info

Ansible Configurations (default): check the below location for ansible defaults configuration file and inventory file

  • Default Config Directory : /etc/ansible
  • Default Config File : /etc/ansible/ansible.cfg
  • Default Inventory File : /etc/ansible/hosts

Now that you’ve installed Ansible, it’s time to get started with some basics.

Step 3: Configuring communication between Ansible Master node and target machines

When Ansible communicates with the target machines, by default it assumes the ssh keys are exchanged and password less communication is through. If you want to use the password, can hard-code the password in the inventory file,  but this is not recommended. Also, use ssh-keys for communication.

First, create one common user(ansadm) on both sides to communicate Ansible Master node with remote hosts.

Provide full sudo with no password for ansadm user


Step 1. Generating the Keys on Ansible Master Server (ansmaster):

The first thing,  switch from root user to ansadm user, then create ssh keys

Generating ssh keys with 4096 encryption level for ansadm user


1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

Step 2. Update Keys on Remote Host

Passing ssh keys from Ansible Master Server (ansmaster) to remote hosts,  first time it will ask for the user password

Remote Host 1 ( awscli.devopmates.com =

Remote Host 2 (testdb3.devopsmates.com =

1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

Remote Host 3 (webapp1.devopsmates.com =

1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

Step 3. Testing the Public Key Authentication

1x1.trans - Ansible Installation and Configuration on Redhat/CentOS 7

We’ll assume you are using SSH keys for authentication. To set up SSH agent to avoid retyping passwords, you can do: after transferring the ssh keys, the next basic task is to create inventory for remote hosts. Check out next page to create an inventory file.

Comments (18)

  • Very Good article

  • Hey! Someone in my Myspace group shared this site with us so I came to take a look.

    I’m definitely enjoying the information. I’m book-marking and will be
    tweeting this to my followers! Wonderful blog and fantastic design.

  • We are a bunch of volunteers and opening a brand new scheme in our community. Your web site provided us with useful information to work on. You have performed a formidable activity and our entire group will likely be thankful to you.

  • Howdy! This post couldn’t be written any better!
    Reading this post reminds me of my previous
    room mate! He always kept talking about this. I will forward this page to him.
    Fairly certain he will have a good read. Thanks for sharing!

  • I know this website offers quality dependent articles and additional stuff, is
    there any other website which provides these stuff in quality?

  • Utterly composed subject material, appreciate it for entropy.

  • Hi, I do believe this is an excellent website. I stumbledupon it 😉 I may return yet again since i have saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to guide others.

  • Way cool! Some very valid points! I appreciate you penning this post plus the rest of the website is extremely good.

  • I’m not sure where you are getting your information, however great topic. I must spend a while studying more or working out more. Thank you for fantastic information I used to be looking for this information for my mission.

  • After looking over a few of the blog posts on your blog, I honestly like your way of writing a blog. I book-marked it to my bookmark website list and will be checking back soon. Take a look at my web site as well and let me know what you think.

  • Hi Mate,

    Could you please reproduce same thing with Ansible tower and write some article like this

  • Awesome document. Please keep share the knowledge

  • I simply want to say I’m beginner to weblog and absolutely loved your blog. Almost certainly I’m likely to bookmark your website . You definitely come with superb posts. Regards for sharing with us your web-site.

  • Hello there, just became aware of your blog through Google, and found
    that it is really informative. I am gonna watch out for
    brussels. I will be grateful if you continue this in future.

    Numerous people will be benefited from your writing.

  • Wonderful post however I was wondering if you could write a litte more on this topic?
    I’d be very grateful if you could elaborate a little bit further.
    Thank you!

  • Do you mind if I quote a few of your posts
    as long as I provide credit and sources back to your site?
    My blog is in the very same area of interest as yours and
    my visitors would genuinely benefit from a lot of the information you present
    here. Please let me know if this ok with you. Appreciate it!


Leave a Reply

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

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