• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to Install and configure Ansible on Centos 7

  • 00:52 lsb_release -d
  • 01:07 yum -y install epel-release
  • 01:21 yum -y install ansible
  • 01:37 ansible --version
  • 01:56 ssh-keygen
  • 02:06 ssh-copy-id root@192.168.6.111
  • 02:31 ssh root@192.168.6.111
  • 02:43 vi /etc/ansible/hosts
  • 03:01 ansible -m ping all
{{postValue.id}}

To Install and configure Ansible on Centos 7

Introduction:

Ansible is a software tool that implements simple and powerful automation for cross-platform computer support which is fundamentally designed for IT professionals, who utilize it for application deployment. It also depends on agent software and has no further security infrastructure to deploy.

Configuration of ansible:

Check the Os version by using following command:

 [root@linuxhelp ~]# lsb_release -d
Description:	CentOS Linux release 7.6.1810 (Core)

Install EPEL Repository:

[root@linuxhelp ~]# yum -y install epel-release

Run the following command to install the latest version of Ansible.

[root@linuxhelp ~]# yum -y install ansible

Check the Ansible version by running following command:

[root@linuxhelp ~]# ansible --version
ansible 2.9.18
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

Configure Ansible hosts file by adding the content of client machine:

[root@linuxhelp ~]# vi /etc/ansible/hosts
Then add the following line in hosts file:
[ansible]
Client ansible_host=192.168.6.111 ansible_user=root

Generate an SSH key pair on your system by running the command.

[root@linuxhelp ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Swic9qeSRlO3m1anc8d0i2GaI9oktubD9JTF1AyiPRY root@linuxhelp.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|         E .+    |
|   . .  o o. o   |
|    = ...+o      |
|   . + o...o     |
|    o o S + .o. .|
|   . o = B o+oo..|
|    + +oBoo+..o. |
|   . ..=*..o..   |
|      o+..       |
+----[SHA256]-----+

Copy the Public Key into Client machine:

 [root@linuxhelp ~]# ssh-copy-id root@192.168.6.111
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.6.111 (192.168.6.111)' can't be established.
ECDSA key fingerprint is SHA256:ZDQCylNTkOyDJ0FfhrHjVl7ExwVfZn96WQBFm1jspE8.
ECDSA key fingerprint is MD5:ac:f6:60:84:22:7f:a7:19:0f:69:5a:97:79:b7:39:dd.
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.6.111's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'root@192.168.6.111'"
and check to make sure that only the key(s) you wanted were added.

Take ssh of the client machine:

[root@linuxhelp ~]# ssh root@192.168.6.111
Last login: Tue Mar 30 00:10:23 2021

Connect using Ansible:

[root@linuxhelp ~]# ansible -m ping all
Client | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}

With this method Installation and configuration of Ansible on Centos 7 comes to an end.

Tags:
owen
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is Ansible?

A

Ansible is a software tool that provides simple but powerful automation for cross-platform computer support. It is primarily intended for IT professionals, who use it for application deployment, updates on workstations and servers, cloud provisioning, configuration management, intra-service orchestration, and nearly anything a systems administrator does on a weekly or daily basis. Ansible doesn't depend on agent software and has no additional security infrastructure, so it's easy to deploy.

Q

Can Ansible run on Windows?

A

No, Ansible can only manage Windows hosts. Ansible cannot run on a Windows host natively, though it can run under the Windows Subsystem for Linux (WSL).

Q

What is the command to install the ansible repository package?

A

#sudo yum -y install epel-release

Q

What is the command to install ansible?

A

#sudo yum -y install ansible

Q

What are the Ansible Modules?

A

There are 2 types of modules in Ansible:
i)Core modules
ii)Extras modules

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.