install ansible on centos 7

How to install ansible on centos 7 | Ansible Installation

This article explains about the ansible installation. Before creating playbook, we should have knowledge about How to install ansible on centos.

You can also visity the below topics.

Ansible Tutorial | What is Ansible | Learning Ansible basics
What is Ansible Configuration Files Explained with Examples 


Befor going to ansible installation, Below are the highlights

Control Node

  • Ansible is uses agentless architecture
  • Differs from other configuration management utilities like Puppet, Chef
  • Software installs on control node
  • Only requirement: Python version 2.6 or later

To check installed Python version:

  • [root@myaansible ~]# yum list python

Installed Packages
python.x86_64                                             2.7.5-90.el7                                        installed
[root@myaansible ~]#

Managed Hosts

  • No special Ansible agent needed
  • Control node communicates with managed hosts over network
  • SSH connection used by default
  • Ansible normally connects to managed hosts using same username running Ansible on control node
  • SSH sessions require authentication at initiation of each connection
    Password authentication for each connection becomes unwieldy as number of managed hosts increases
  • Key-based authentication preferable in enterprise environments

Configure Ansible Controller

Here, you set up and configure the myaansible host as the Ansible Controller server.
You use a automon user on the Ansible Controller and generate an SSH key pair for the user. The automon user is used to run all of the Ansible CLI commands to manage the remote hosts.

install ansible on centos 7

Install Ansible

ansible installation on the myaansible host 

  • Install ansible on centos 7, Red-Hat 
  • [root@myaansible ~]# yum install ansible

Package                                  Arch           Version            Repository          Size
ansible                                   noarch         2.9.25-1.el7    epel                       17 M
Installing for dependencies:
python-jinja2                           noarch      2.7.2-4.el7       base                     519 k

Transaction Summary
Install 1 Package (+1 Dependent package)

Total download size: 18 M
Installed size: 106 M
Is this ok [y/d/N]: y
Downloading packages:
(1/2): python-jinja2-2.7.2-4.el7.noarch.rpm | 519 kB 00:00:00
(2/2): ansible-2.9.25-1.el7.noarch.rpm | 17 MB 00:00:04
Total 3.6 MB/s | 18 MB 00:00:04
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-jinja2-2.7.2-4.el7.noarch 1/2
Installing : ansible-2.9.25-1.el7.noarch 2/2
Verifying : python-jinja2-2.7.2-4.el7.noarch 1/2
Verifying : ansible-2.9.25-1.el7.noarch 2/2

ansible.noarch 0:2.9.25-1.el7

Dependency Installed:
python-jinja2.noarch 0:2.7.2-4.el7


install ansible on ubuntu

  • If you using ubuntu system then run below command.
  • [root@myaansible ~]# apt install ansible

Generate SSH Key Pair

  1. Generate an SSH key pair for the automon user:

[automon@myaansible ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/automon/.ssh/id_rsa):
Created directory ‘/home/automon/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/automon/.ssh/id_rsa.
Your public key has been saved in /home/automon/.ssh/
The key fingerprint is:
The key’s randomart image is:
+—[RSA 2048]—-+
|   ..      .o  .+       ..o @|
|   ..    .o =    .+o    o..*|
|   o.o     o.+     .E  .+o|
| . .       +o o           ++|
|                       ..S= ..+|
|                          + . o. |
|                           . ..+…|
|                         o+.o.+|
|                          .oo .o|

  • Verify that the SSH key was successfully created:
    • [automon@myaansible ~]$ ls -la .ssh/
    • -rw——-. 1 automon automon 1675 Sep 12 07:45 id_rsa
    • -rw-r–r–. 1 automon automon 404 Sep 12 07:45

Set Up Remote Host

Here, you set up the remote hosts. You create the automon user on all of the remote hosts and copy its public key to each host.

  • The automon user on the myaansible host is already set up to connect to the remote host as node1.


  • Before using key-based authentication, need to copy public key to destination system
  • To do this, use ssh-copy-id:
  • [automon@myaansible ~]$ ssh-copy-id automon@node1
    • If you not using DNS the you can use system IP
    • If you have multiple Remote Hosts then do same steps
  • After copying key, use key-based authentication to authenticate SSH connections to host
    • Ready-to-use tools for specific tasks
    • Run from command line or use in playbooks

Support us: If you like this post, Share with your friends and groups

Related Posts

Leave a Reply

Your email address will not be published.