Thursday 13 February 2020

Ansible AD HOC commands examples

1
=======
Use the ping module to ping all the nodes in your inventory:-

[sai@san-master-anisble ~]$cat /etc/ansible/hosts
192.161.1.10

[sai@san-master-anisble ~]$ ansible all -m ping -u root -k
SSH password: 
192.161.1.10| SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "ping": "pong"
}


2.
===
[root@san-master-anisble ~]# ansible webservers -m shell -a "/sbin/reboot" -u root -k
SSH password: 
192.161.1.11 | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: Shared connection to 10.219.39.151 closed.", 
    "unreachable": true
}


3.
=============from Control server to Traget Server=============
[root@san-master-anisble opt]# ansible webservers -m copy -a "src=/opt/test2.txt dest=/tmp/test2.txt" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "checksum": "cdcdb882c45c507f08092f6247ca0c25b13e4ee6", 
    "dest": "/tmp/test2.txt", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "fe42c7a375851a6e6ab6efd67b8895f8", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "unconfined_u:object_r:admin_home_t:s0", 
    "size": 14, 
    "src": "/root/.ansible/tmp/ansible-tmp-1580943557.82-148407876984882/source", 
    "state": "file", 
    "uid": 0
}
[root@san-master-anisble opt]# 


4.
================================Ctrl:-managed server to managed server================
[root@san-master-anisble ~]# ansible webservers -m copy -a "src=/opt/test1.txt dest=/tmp/test1.txt remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "checksum": "dfd5f9682ccd17adb12394fd1e01ed677e6bf5f2", 
    "dest": "/tmp/test1.txt", 
    "gid": 0, 
    "group": "root", 
    "md5sum": "de556121cc4cbc5b33dde4ec60ee507f", 
    "mode": "0644", 
    "owner": "root", 
    "secontext": "unconfined_u:object_r:user_tmp_t:s0", 
    "size": 25, 
    "src": "/opt/test1.txt", 
    "state": "file", 
    "uid": 0
}


5.
==============
[root@san-master-anisble opt]# ansible webservers -m file -a "dest=/opt/test1.txt mode=644 remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 0, 
    "group": "root", 
    "mode": "0644", 
    "owner": "root", 
    "path": "/opt/test1.txt", 
    "secontext": "unconfined_u:object_r:usr_t:s0", 
    "size": 25, 
    "state": "file", 
    "uid": 0
}
[root@san-master-anisble opt]# 


6.
==================================

[root@san-master-anisble opt]# ansible local -m file -a "dest=/opt/test2.txt mode=755" -u root -k
SSH password: 
192.161.1.10 | FAILED! => {
    "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."
}


7.
-----
[root@san-master-anisble opt]# ansible local -m file -a "dest=/opt/test2.txt mode=755" -u root -k
SSH password: 
192.161.1.10 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 0, 
    "group": "root", 
    "mode": "0755", 
    "owner": "root", 
    "path": "/opt/test2.txt", 
    "secontext": "unconfined_u:object_r:usr_t:s0", 
    "size": 14, 
    "state": "file", 
    "uid": 0
}
[root@san-master-anisble opt]# ls -ltrh


8.
=========how to delete files on control server ==
[root@san-master-anisble opt]# ansible local  -m file -a "dest=/opt/test2.txt state=absent" -u root -k
SSH password: 
192.161.1.10 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "path": "/opt/test2.txt", 
    "state": "absent"
}
[root@san-master-anisble opt]# 



9.
============how to delete files on managed server 
[root@san-master-anisble opt]# ansible webservers -m file -a "dest=/opt/test1.txt state=absent remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "path": "/opt/test1.txt", 
    "state": "absent"
}


10.
[root@san-master-anisble opt]# ansible webservers -m file -a "path=/opt/a state=absent remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11| CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "path": "/opt/a", 
    "state": "absent"
}
[root@san-master-anisble opt]# 


11.
========managed servers file permission/ownership change==========
[root@san-master-anisble tmp]# ansible webservers -m file -a "dest=/opt/yum.log mode=755 owner=noc group=noc  remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 1000, 
    "group": "noc", 
    "mode": "0755", 
    "owner": "noc", 
    "path": "/opt/yum.log", 
    "secontext": "system_u:object_r:usr_t:s0", 
    "size": 0, 
    "state": "file", 
    "uid": 1000
}
[root@san-master-anisble tmp]# 


12.
=========================Dir creation on managed server=========
[root@san-master-anisble tmp]# ansible webservers -m file -a "dest=/opt/sankar mode=755 owner=noc group=noc state=directory  remote_src=TRUE" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "gid": 1000, 
    "group": "noc", 
    "mode": "0755", 
    "owner": "noc", 
    "path": "/opt/sankar", 
    "secontext": "unconfined_u:object_r:usr_t:s0", 
    "size": 6, 
    "state": "directory", 
    "uid": 1000
}
[root@san-master-anisble tmp]# 


13.
=========managing packages in managed servers===
[root@san-master-anisble tmp]# ansible webservers -m yum -a "name=http* state=present" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "changes": {
        "installed": [
            "http*"
        ]
    }, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "Loaded plugins: fastestmirror\nLoading mirror speeds from cached hostfile\n * base: centos.excellmedia.net\n * 
....
....
....

 
14.  
======== latest version update ====
[root@san-master-anisble tmp]# ansible webservers -m yum -a "name=http* state=latest" -u root -k
SSH password: 
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": false, 
    "changes": {
        "installed": [], 
        "updated": []
    }, 
    "msg": "", 
    "rc": 0, 
    "results": [
        "All packages providing http* are up to date", 
        ""
    ]
}
[root@san-master-anisble tmp]# 


14.
=========service madule on managed server(start http service start)
[root@san-master-anisble tmp]# ansible  webservers -m service -a "name=httpd state=started" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "httpd", 
    "state": "started", 
.....
.....


16.
---- stopped service on managed server ===

[root@san-master-anisble tmp]# ansible  webservers -m service -a "name=httpd state=stopped" -u root -k
SSH password: 
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "name": "httpd", 
    "state": "stopped", 
.....
.....


17.
============== Gathering facts(discoverd variables about a system =========
[root@san-master-anisble tmp]# ansible all -m setup -u root -k
SSH password: 
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "10.219.39.151"
        ], 
        "ansible_all_ipv6_addresses": [
            "fe80::dbdb:a08a:cf20:ddb2"
        ], 
        "ansible_apparmor": {
            "status": "disabled"
        }, 
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "12/01/2006", 
        "ansible_bios_version": "VirtualBox", 
        "ansible_cmdline": {
            "BOOT_IMAGE": "/vmlinuz-3.10.0-1062.9.1.el7.x86_64", 
            "LANG": "en_US.UTF-8", 
            "crashkernel": "auto", 
            "quiet": true, 
            "rd.lvm.lv": "cl/swap", 
            "rhgb": true, 
            "ro": true, 
            "root": "/dev/mapper/cl-root"
        }, 
        "ansible_date_time": {
....
....
....



18.
===== user creation ======
[root@san-master-anisble ~]# ansible all -m user -a "name=sai1 password=sai@123" -u root -k
SSH password: 
[WARNING]: The input password appears not to have been hashed. The 'password' argument must be encrypted for this module to work properly.
192.161.1.11 | CHANGED => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    }, 
    "changed": true, 
    "comment": "", 
    "create_home": true, 
    "group": 1001, 
    "home": "/home/sai1", 
    "name": "sai1", 
    "password": "NOT_LOGGING_PASSWORD", 
    "shell": "/bin/bash", 
    "state": "present", 
    "system": false, 
    "uid": 1001
}


19.
------------------------------------------------------------------------
[root@san-master-anisble ~]# ansible localhost -m ping -e 'ansible_python_interpreter="/usr/bin/env python"'
localhost | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
[root@san-master-anisble ~]# 


20.
--
[root@san-master-anisble ~]# ansible --version
ansible 2.9.2
  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, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@san-master-anisble ~]# 


21.
---
[root@san-master-anisble ~]# ansible-config --version
ansible-config 2.9.2
  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-config
  python version = 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@san-master-anisble ~]# 

Tuesday 4 February 2020

First Ansible:-Use the ping module to ping all the nodes in your inventory

Use the ping module to ping all the nodes in your inventory:

[sai@san-master-anisble ~]$cat /etc/ansible/hosts
192.161.1.10

[sai@san-master-anisble ~]$ ansible all -m ping -u root -k
SSH password:
192.161.1.10| SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}


[sai@san-master-anisble ~]$ ansible all -a "/bin/echo hello" -u root -k
SSH password:
192.161.1.11 | CHANGED | rc=0 >>
hello
[sai@san-master-anisble ~]$


If you need privilege escalation (sudo) to run a command, pass the become flags:
Case1:- noc // from noc user switched to root

[sai@san-master-anisble ~]$ ansible all -m ping -u noc --become
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}

Case 2: from noc user to switch to noc1
[sai@san-master-anisble ~]$ ansible all -m ping -u noc --become --become-user noc1
192.161.1.11 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python"
    },
    "changed": false,
    "ping": "pong"
}
[sai@san-master-anisble ~]$ 

Steps how to install letest ansible version on CentOS7

Step1: Verify current version
[root@san-ansible ~]# ansible --version
ansible 2.4.2.0
  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, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@san-ansible ~]#


Step2: verify upgrade process.
[root@san-ansible ~]# yum -y update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
No packages marked for update
[root@san-ansible ~]#

Step3: Verify epel repo is installed or not?
[root@san-ansible ~]# yum -y install epel-repo
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
No package epel-repo available.
Error: Nothing to do

[root@san-ansible ~]# yum search epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
=============================================================== N/S matched: epel-release ================================================================
epel-release.noarch : Extra Packages for Enterprise Linux repository configuration

  Name and summary matches only, use "search all" for everything.

[root@san-ansible ~]# yum info epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
Available Packages
Name        : epel-release
Arch        : noarch
Version     : 7
Release     : 11
Size        : 15 k
Repo        : extras/7/x86_64
Summary     : Extra Packages for Enterprise Linux repository configuration
URL         : http://download.fedoraproject.org/pub/epel
License     : GPLv2
Description : This package contains the Extra Packages for Enterprise Linux (EPEL) repository
            : GPG key as well as configuration for yum.


Step4: Install epel repo on CentOS-7
[root@san-ansible ~]# yum install epel-release
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                                  Arch                               Version                             Repository                          Size
==========================================================================================================================================================
Installing:
 epel-release                             noarch                             7-11                                extras                              15 k

Transaction Summary
==========================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-11.noarch.rpm                                                                                                       |  15 kB  00:00:00   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                               1/1
  Verifying  : epel-release-7-11.noarch                                                                                                               1/1

Installed:
  epel-release.noarch 0:7-11                                                                                                                           

Complete!

Step6: Verify upgrade process if any new packeges are there?
[root@san-ansible ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
epel/x86_64/metalink                                                                                                               | 7.5 kB  00:00:00   
 * base: mirrors.piconets.webwerks.in
 * epel: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
epel                                                                                                                               | 5.3 kB  00:00:00   
(1/3): epel/x86_64/group_gz                                                                                                        |  90 kB  00:00:00   
(2/3): epel/x86_64/updateinfo                                                                                                      | 1.0 MB  00:00:01   
(3/3): epel/x86_64/primary_db                                                                                                      | 6.9 MB  00:00:07   
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.4.2.0-2.el7 will be updated
---> Package ansible.noarch 0:2.9.2-1.el7 will be an update
---> Package epel-release.noarch 0:7-11 will be updated
---> Package epel-release.noarch 0:7-12 will be an update
---> Package python-passlib.noarch 0:1.6.5-2.el7 will be obsoleted
---> Package python2-passlib.noarch 0:1.7.1-1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                                   Arch                             Version                                  Repository                      Size
==========================================================================================================================================================
Installing:
 python2-passlib                           noarch                           1.7.1-1.el7                              epel                           741 k
     replacing  python-passlib.noarch 1.6.5-2.el7
Updating:
 ansible                                   noarch                           2.9.2-1.el7                              epel                            17 M
 epel-release                              noarch                           7-12                                     epel                            15 k

Transaction Summary
==========================================================================================================================================================
Install  1 Package
Upgrade  2 Packages

Total download size: 18 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/epel/packages/epel-release-7-12.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY|    0 B  --:--:-- ETA
Public key for epel-release-7-12.noarch.rpm is not installed
(1/3): epel-release-7-12.noarch.rpm                                                                                                |  15 kB  00:00:00   
(2/3): ansible-2.9.2-1.el7.noarch.rpm                                                                                              |  17 MB  00:00:19   
(3/3): python2-passlib-1.7.1-1.el7.noarch.rpm                                                                                      | 741 kB  00:00:00   
----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                     914 kB/s |  18 MB  00:00:20   
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Importing GPG key 0x352C64E5:
 Userid     : "Fedora EPEL (7) <epel@fedoraproject.org>"
 Fingerprint: 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
 Package    : epel-release-7-11.noarch (@extras)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : ansible-2.9.2-1.el7.noarch                                                                                                             1/6
  Updating   : epel-release-7-12.noarch                                                                                                               2/6
  Installing : python2-passlib-1.7.1-1.el7.noarch                                                                                                     3/6
  Cleanup    : ansible-2.4.2.0-2.el7.noarch                                                                                                           4/6
  Erasing    : python-passlib-1.6.5-2.el7.noarch                                                                                                      5/6
  Cleanup    : epel-release-7-11.noarch                                                                                                               6/6
  Verifying  : python2-passlib-1.7.1-1.el7.noarch                                                                                                     1/6
  Verifying  : epel-release-7-12.noarch                                                                                                               2/6
  Verifying  : ansible-2.9.2-1.el7.noarch                                                                                                             3/6
  Verifying  : python-passlib-1.6.5-2.el7.noarch                                                                                                      4/6
  Verifying  : epel-release-7-11.noarch                                                                                                               5/6
  Verifying  : ansible-2.4.2.0-2.el7.noarch                                                                                                           6/6

Installed:
  python2-passlib.noarch 0:1.7.1-1.el7                                                                                                                 

Updated:
  ansible.noarch 0:2.9.2-1.el7                                                 epel-release.noarch 0:7-12                                             

Replaced:
  python-passlib.noarch 0:1.6.5-2.el7                                                                                                                   

Complete!

[root@san-ansible ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
repo id                                                    repo name                                                                                status
base/7/x86_64                                              CentOS-7 - Base                                                                          10,097
epel/x86_64                                                Extra Packages for Enterprise Linux 7 - x86_64                                           13,523
extras/7/x86_64                                            CentOS-7 - Extras                                                                           323
updates/7/x86_64                                           CentOS-7 - Updates                                                                        1,117
repolist: 25,060


Step7: take a backup of existing configs and remove the older version.
[root@san-ansible ~]# yum remove ansible
Loaded plugins: fastestmirror
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.9.2-1.el7 will be erased
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                             Arch                               Version                                   Repository                         Size
==========================================================================================================================================================
Removing:
 ansible                             noarch                             2.9.2-1.el7                               @epel                             104 M

Transaction Summary
==========================================================================================================================================================
Remove  1 Package

Installed size: 104 M
Is this ok [y/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Erasing    : ansible-2.9.2-1.el7.noarch                                                                                                             1/1
  Verifying  : ansible-2.9.2-1.el7.noarch                                                                                                             1/1

Removed:
  ansible.noarch 0:2.9.2-1.el7                                                                                                                 

Complete!


Step8: Install the latest version. 
[root@san-ansible ~]# yum install ansible
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.piconets.webwerks.in
 * epel: mirrors.piconets.webwerks.in
 * extras: mirrors.piconets.webwerks.in
 * updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.9.2-1.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================================================================
 Package                             Arch                               Version                                    Repository                        Size
==========================================================================================================================================================
Installing:
 ansible                             noarch                             2.9.2-1.el7                                epel                              17 M

Transaction Summary
==========================================================================================================================================================
Install  1 Package

Total download size: 17 M
Installed size: 104 M
Is this ok [y/d/N]: y
Downloading packages:
ansible-2.9.2-1.el7.noarch.rpm                                                                                                     |  17 MB  00:00:07   
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : ansible-2.9.2-1.el7.noarch                                                                                                             1/1
  Verifying  : ansible-2.9.2-1.el7.noarch                                                                                                             1/1

Installed:
  ansible.noarch 0:2.9.2-1.el7                                                                                                                         
Complete!
[root@san-ansible ~]#
[root@san-ansible ~]#
[root@san-ansible ~]#
[root@san-ansible ~]#

[root@san-ansible ~]# ansible --version
ansible 2.9.2
  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, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@san-ansible ~]#