Total Pageviews

Monday 12 November 2018

Ansible Basic


Ansible Inventory - 3
The web servers are linux, but the db server is windows. Add additional parameters in each line to add ansible_connection, ansible_user and password.
Use the below table for information about credentials.

Note: For Linux use ansible_ssh_pass and for Windows use ansible_password for the password field. Connector for windows is winrm
Answer:
# Web Servers
web1 ansible_host=server1.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web2 ansible_host=server2.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web3 ansible_host=server3.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!

# Database Servers
db1 ansible_host=server4.company.com ansible_connection=winrm ansible_user=administrator ansible_password=Password123!

Ansible Inventory - 5

Let us now create a group of groups. Create a new group called 'all_servers' and add the previously created groups 'web_servers' and 'db_servers' to it.
Syntax:
[parent_group:children]
child_group1
child_group2
Answer:
# Web Servers
web1 ansible_host=server1.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web2 ansible_host=server2.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!
web3 ansible_host=server3.company.com ansible_connection=ssh ansible_user=root ansible_ssh_pass=Password123!

# Database Servers
db1 ansible_host=server4.company.com ansible_connection=winrm ansible_user=administrator ansible_password=Password123!


[web_servers]
web1
web2
web3

[db_servers]
db1

[all_servers:children]
web_servers
db_servers

Ansible Inventory - 6

Try and represent the data given in the below table in Ansible Inventory format


Ansible Server Installation with other opensource and python repository

[root@ip-172-31-44-223 ~]# yum install wget
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-15.el7_4.1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package Arch      Version            Repository                           Size
================================================================================
Installing:
 wget    x86_64    1.14-15.el7_4.1    rhui-REGION-rhel-server-releases    547 k

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

Total download size: 547 k
Installed size: 2.0 M
Is this ok [y/d/N]: y
Downloading packages:
wget-1.14-15.el7_4.1.x86_64.rpm                            | 547 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : wget-1.14-15.el7_4.1.x86_64                                  1/1
  Verifying  : wget-1.14-15.el7_4.1.x86_64                                  1/1

Installed:
  wget.x86_64 0:1.14-15.el7_4.1

Complete!




====================Configure OpenSource Project repository =================




[root@ip-172-31-44-223 ~]# wget https://dl.fedoraproject.org/pub/epel/epel-relea                                                                                        se-latest-7.noarch.rpm
--2018-03-26 21:32:59--  https://dl.fedoraproject.org/pub/epel/epel-release-late                                                                                        st-7.noarch.rpm
Resolving dl.fedoraproject.org (dl.fedoraproject.org)... 209.132.181.24, 209.132                                                                                        .181.25, 209.132.181.23
Connecting to dl.fedoraproject.org (dl.fedoraproject.org)|209.132.181.24|:443...                                                                                         connected.
HTTP request sent, awaiting response... 200 OK
Length: 15080 (15K) [application/x-rpm]
Saving to: ‘epel-release-latest-7.noarch.rpm’

100%[======================================>] 15,080      --.-K/s   in 0.04s

2018-03-26 21:33:00 (350 KB/s) - ‘epel-release-latest-7.noarch.rpm’ saved [15080                                                                                        /15080]

[root@ip-172-31-44-223 ~]# rpm -ivh epel-release-latest-7.noarch.rpm
warning: epel-release-latest-7.noarch.rpm: Header V3 RSA/SHA256 Signature, key I                                                                                        D 352c64e5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:epel-release-7-11                ################################# [100%]
[root@ip-172-31-44-223 ~]# yum install epel-release
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
epel/x86_64/metalink                                     |  16 kB     00:00
epel                                                     | 4.7 kB     00:00
(1/3): epel/x86_64/group_gz                                | 266 kB   00:00
(2/3): epel/x86_64/updateinfo                              | 904 kB   00:01
(3/3): epel/x86_64/primary_db                              | 6.3 MB   00:07
Package epel-release-7-11.noarch already installed and latest version
Nothing to do
[root@ip-172-31-44-223 ~]#
[root@ip-172-31-44-223 ~]# yum install python
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Package python-2.7.5-58.el7.x86_64 already installed and latest version
Nothing to do
[root@ip-172-31-44-223 ~]# yum install python-pip
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                    Arch                                  Version                                     Repository                           Size
========================================================================================================================================================================
Installing:
 python2-pip                                noarch                                8.1.2-5.el7                                 epel                                1.7 M

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

Total download size: 1.7 M
Installed size: 7.2 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/epel/packages/python2-pip-8.1.2-5.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
Public key for python2-pip-8.1.2-5.el7.noarch.rpm is not installed
python2-pip-8.1.2-5.el7.noarch.rpm                                                                                                               | 1.7 MB  00:00:00
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 (installed)
 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
Warning: RPMDB altered outside of yum.
  Installing : python2-pip-8.1.2-5.el7.noarch                                                                                                                       1/1
  Verifying  : python2-pip-8.1.2-5.el7.noarch                                                                                                                       1/1

Installed:
  python2-pip.noarch 0:8.1.2-5.el7

Complete!
[root@ip-172-31-44-223 ~]#
[root@ip-172-31-44-223 ~]# pip install --upgrade pip
Collecting pip
  Downloading pip-9.0.3-py2.py3-none-any.whl (1.4MB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 1.4MB 801kB/s
Installing collected packages: pip
  Found existing installation: pip 8.1.2
    Uninstalling pip-8.1.2:
      Successfully uninstalled pip-8.1.2
Successfully installed pip-9.0.3
[root@ip-172-31-44-223 ~]# sudo pip install markupsafe
Requirement already satisfied: markupsafe in /usr/lib64/python2.7/site-packages
[root@ip-172-31-44-223 ~]# sudo pip install xmltodict
Collecting xmltodict
  Downloading xmltodict-0.11.0-py2.py3-none-any.whl
Installing collected packages: xmltodict
Successfully installed xmltodict-0.11.0
[root@ip-172-31-44-223 ~]# sudo pip install pywinrm
Collecting pywinrm
  Downloading pywinrm-0.3.0-py2.py3-none-any.whl
Requirement already satisfied: six in /usr/lib/python2.7/site-packages (from pywinrm)
Collecting requests-ntlm>=0.3.0 (from pywinrm)
  Downloading requests_ntlm-1.1.0-py2.py3-none-any.whl
Collecting requests>=2.9.1 (from pywinrm)
  Downloading requests-2.18.4-py2.py3-none-any.whl (88kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 92kB 4.9MB/s
Requirement already satisfied: xmltodict in /usr/lib/python2.7/site-packages (from pywinrm)
Collecting cryptography>=1.3 (from requests-ntlm>=0.3.0->pywinrm)
  Downloading cryptography-2.2.1-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 2.2MB 530kB/s
Collecting ntlm-auth>=1.0.2 (from requests-ntlm>=0.3.0->pywinrm)
  Downloading ntlm_auth-1.1.0-py2.py3-none-any.whl
Collecting certifi>=2017.4.17 (from requests>=2.9.1->pywinrm)
  Downloading certifi-2018.1.18-py2.py3-none-any.whl (151kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 153kB 6.4MB/s
Collecting chardet<3.1.0,>=3.0.2 (from requests>=2.9.1->pywinrm)
  Downloading chardet-3.0.4-py2.py3-none-any.whl (133kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 143kB 5.9MB/s
Collecting idna<2.7,>=2.5 (from requests>=2.9.1->pywinrm)
  Downloading idna-2.6-py2.py3-none-any.whl (56kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 61kB 9.3MB/s
Collecting urllib3<1.23,>=1.21.1 (from requests>=2.9.1->pywinrm)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 133kB 6.7MB/s
Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm)
  Downloading cffi-1.11.5-cp27-cp27mu-manylinux1_x86_64.whl (407kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 409kB 2.6MB/s
Collecting enum34; python_version < "3" (from cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm)
  Downloading enum34-1.1.6-py2-none-any.whl
Collecting asn1crypto>=0.21.0 (from cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm)
  Downloading asn1crypto-0.24.0-py2.py3-none-any.whl (101kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 102kB 9.2MB/s
Collecting ipaddress; python_version < "3" (from cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm)
  Downloading ipaddress-1.0.19.tar.gz
Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography>=1.3->requests-ntlm>=0.3.0->pywinrm)
  Downloading pycparser-2.18.tar.gz (245kB)
    100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 256kB 4.1MB/s
Installing collected packages: certifi, chardet, idna, urllib3, requests, pycparser, cffi, enum34, asn1crypto, ipaddress, cryptography, ntlm-auth, requests-ntlm, pywinrm
  Found existing installation: chardet 2.2.1
    Uninstalling chardet-2.2.1:
      Successfully uninstalled chardet-2.2.1
  Found existing installation: urllib3 1.10.2
    Uninstalling urllib3-1.10.2:
      Successfully uninstalled urllib3-1.10.2
  Found existing installation: requests 2.6.0
    DEPRECATION: Uninstalling a distutils installed project (requests) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling requests-2.6.0:
      Successfully uninstalled requests-2.6.0
  Running setup.py install for pycparser ... done
  Running setup.py install for ipaddress ... done
Successfully installed asn1crypto-0.24.0 certifi-2018.1.18 cffi-1.11.5 chardet-3.0.4 cryptography-2.2.1 enum34-1.1.6 idna-2.6 ipaddress-1.0.19 ntlm-auth-1.1.0 pycparser-2.18 pywinrm-0.3.0 requests-2.18.4 requests-ntlm-1.1.0 urllib3-1.22
[root@ip-172-31-44-223 ~]#



[root@ip-172-31-44-223 ~]# yum install ansible
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.4.2.0-1.el7 will be installed
--> Processing Dependency: python-crypto for package: ansible-2.4.2.0-1.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.4.2.0-1.el7.noarch
--> Processing Dependency: python-keyczar for package: ansible-2.4.2.0-1.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.4.2.0-1.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.4.2.0-1.el7.noarch
--> Processing Dependency: sshpass for package: ansible-2.4.2.0-1.el7.noarch
--> Running transaction check
---> Package python-httplib2.noarch 0:0.9.2-0.1.el7 will be installed
---> Package python-keyczar.noarch 0:0.71c-2.el7 will be installed
--> Processing Dependency: python-pyasn1 for package: python-keyczar-0.71c-2.el7.noarch
---> Package python-paramiko.noarch 0:2.1.1-0.2.el7 will be installed
--> Processing Dependency: python-cryptography for package: python-paramiko-2.1.1-0.2.el7.noarch
---> Package python2-crypto.x86_64 0:2.6.1-13.el7 will be installed
--> Processing Dependency: libtomcrypt.so.0()(64bit) for package: python2-crypto-2.6.1-13.el7.x86_64
---> Package python2-jmespath.noarch 0:0.9.0-1.el7 will be installed
---> Package sshpass.x86_64 0:1.06-1.el7 will be installed
--> Running transaction check
---> Package libtomcrypt.x86_64 0:1.17-25.el7 will be installed
--> Processing Dependency: libtommath >= 0.42.0 for package: libtomcrypt-1.17-25.el7.x86_64
--> Processing Dependency: libtommath.so.0()(64bit) for package: libtomcrypt-1.17-25.el7.x86_64
---> Package python2-cryptography.x86_64 0:1.7.2-1.el7_4.1 will be installed
--> Processing Dependency: python-cffi >= 1.4.1 for package: python2-cryptography-1.7.2-1.el7_4.1.x86_64
--> Processing Dependency: python-idna >= 2.0 for package: python2-cryptography-1.7.2-1.el7_4.1.x86_64
--> Processing Dependency: python-enum34 for package: python2-cryptography-1.7.2-1.el7_4.1.x86_64
--> Processing Dependency: python-ipaddress for package: python2-cryptography-1.7.2-1.el7_4.1.x86_64
---> Package python2-pyasn1.noarch 0:0.1.9-7.el7 will be installed
--> Running transaction check
---> Package libtommath.x86_64 0:0.42.0-5.el7 will be installed
---> Package python-cffi.x86_64 0:1.6.0-5.el7 will be installed
--> Processing Dependency: python-pycparser for package: python-cffi-1.6.0-5.el7.x86_64
---> Package python-enum34.noarch 0:1.0.4-1.el7 will be installed
---> Package python-idna.noarch 0:2.4-1.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Running transaction check
---> Package python-pycparser.noarch 0:2.14-1.el7 will be installed
--> Processing Dependency: python-ply for package: python-pycparser-2.14-1.el7.noarch
--> Running transaction check
---> Package python-ply.noarch 0:3.4-11.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================================================================
 Package                                   Arch                        Version                              Repository                                             Size
========================================================================================================================================================================
Installing:
 ansible                                   noarch                      2.4.2.0-1.el7                        epel                                                  7.6 M
Installing for dependencies:
 libtomcrypt                               x86_64                      1.17-25.el7                          epel                                                  225 k
 libtommath                                x86_64                      0.42.0-5.el7                         epel                                                   35 k
 python-cffi                               x86_64                      1.6.0-5.el7                          rhui-REGION-rhel-server-releases                      218 k
 python-enum34                             noarch                      1.0.4-1.el7                          rhui-REGION-rhel-server-releases                       52 k
 python-httplib2                           noarch                      0.9.2-0.1.el7                        epel                                                  115 k
 python-idna                               noarch                      2.4-1.el7                            rhui-REGION-rhel-server-releases                       94 k
 python-ipaddress                          noarch                      1.0.16-2.el7                         rhui-REGION-rhel-server-releases                       34 k
 python-keyczar                            noarch                      0.71c-2.el7                          epel                                                  218 k
 python-paramiko                           noarch                      2.1.1-0.2.el7                        epel                                                  267 k
 python-ply                                noarch                      3.4-11.el7                           rhui-REGION-rhel-server-releases                      123 k
 python-pycparser                          noarch                      2.14-1.el7                           rhui-REGION-rhel-server-releases                      105 k
 python2-crypto                            x86_64                      2.6.1-13.el7                         epel                                                  476 k
 python2-cryptography                      x86_64                      1.7.2-1.el7_4.1                      rhui-REGION-rhel-server-releases                      502 k
 python2-jmespath                          noarch                      0.9.0-1.el7                          epel                                                   39 k
 python2-pyasn1                            noarch                      0.1.9-7.el7                          rhui-REGION-rhel-server-releases                      100 k
 sshpass                                   x86_64                      1.06-1.el7                           epel                                                   21 k

Transaction Summary
========================================================================================================================================================================
Install  1 Package (+16 Dependent packages)

Total download size: 10 M
Installed size: 50 M
Is this ok [y/d/N]: y
Downloading packages:
(1/17): ansible-2.4.2.0-1.el7.noarch.rpm                                                                                                         | 7.6 MB  00:00:00
(2/17): libtomcrypt-1.17-25.el7.x86_64.rpm                                                                                                       | 225 kB  00:00:00
(3/17): libtommath-0.42.0-5.el7.x86_64.rpm                                                                                                       |  35 kB  00:00:00
(4/17): python-httplib2-0.9.2-0.1.el7.noarch.rpm                                                                                                 | 115 kB  00:00:00
(5/17): python-enum34-1.0.4-1.el7.noarch.rpm                                                                                                     |  52 kB  00:00:00
(6/17): python-cffi-1.6.0-5.el7.x86_64.rpm                                                                                                       | 218 kB  00:00:00
(7/17): python-ipaddress-1.0.16-2.el7.noarch.rpm                                                                                                 |  34 kB  00:00:00
(8/17): python-keyczar-0.71c-2.el7.noarch.rpm                                                                                                    | 218 kB  00:00:00
(9/17): python-paramiko-2.1.1-0.2.el7.noarch.rpm                                                                                                 | 267 kB  00:00:00
(10/17): python-ply-3.4-11.el7.noarch.rpm                                                                                                        | 123 kB  00:00:00
(11/17): python2-crypto-2.6.1-13.el7.x86_64.rpm                                                                                                  | 476 kB  00:00:00
(12/17): python-idna-2.4-1.el7.noarch.rpm                                                                                                        |  94 kB  00:00:00
(13/17): python2-cryptography-1.7.2-1.el7_4.1.x86_64.rpm                                                                                         | 502 kB  00:00:00
(14/17): python2-jmespath-0.9.0-1.el7.noarch.rpm                                                                                                 |  39 kB  00:00:00
(15/17): python-pycparser-2.14-1.el7.noarch.rpm                                                                                                  | 105 kB  00:00:00
(16/17): python2-pyasn1-0.1.9-7.el7.noarch.rpm                                                                                                   | 100 kB  00:00:00
(17/17): sshpass-1.06-1.el7.x86_64.rpm                                                                                                           |  21 kB  00:00:00
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                   7.0 MB/s |  10 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python2-pyasn1-0.1.9-7.el7.noarch                                                                                                                   1/17
  Installing : python2-jmespath-0.9.0-1.el7.noarch                                                                                                                 2/17
  Installing : libtommath-0.42.0-5.el7.x86_64                                                                                                                      3/17
  Installing : libtomcrypt-1.17-25.el7.x86_64                                                                                                                      4/17
  Installing : python2-crypto-2.6.1-13.el7.x86_64                                                                                                                  5/17
  Installing : python-keyczar-0.71c-2.el7.noarch                                                                                                                   6/17
  Installing : python-enum34-1.0.4-1.el7.noarch                                                                                                                    7/17
  Installing : python-ipaddress-1.0.16-2.el7.noarch                                                                                                                8/17
  Installing : sshpass-1.06-1.el7.x86_64                                                                                                                           9/17
  Installing : python-httplib2-0.9.2-0.1.el7.noarch                                                                                                               10/17
  Installing : python-ply-3.4-11.el7.noarch                                                                                                                       11/17
  Installing : python-pycparser-2.14-1.el7.noarch                                                                                                                 12/17
  Installing : python-cffi-1.6.0-5.el7.x86_64                                                                                                                     13/17
  Installing : python-idna-2.4-1.el7.noarch                                                                                                                       14/17
  Installing : python2-cryptography-1.7.2-1.el7_4.1.x86_64                                                                                                        15/17
  Installing : python-paramiko-2.1.1-0.2.el7.noarch                                                                                                               16/17
  Installing : ansible-2.4.2.0-1.el7.noarch                                                                                                                       17/17
  Verifying  : python-keyczar-0.71c-2.el7.noarch                                                                                                                   1/17
  Verifying  : python-idna-2.4-1.el7.noarch                                                                                                                        2/17
  Verifying  : python-ply-3.4-11.el7.noarch                                                                                                                        3/17
  Verifying  : python-httplib2-0.9.2-0.1.el7.noarch                                                                                                                4/17
  Verifying  : ansible-2.4.2.0-1.el7.noarch                                                                                                                        5/17
  Verifying  : python-pycparser-2.14-1.el7.noarch                                                                                                                  6/17
  Verifying  : sshpass-1.06-1.el7.x86_64                                                                                                                           7/17
  Verifying  : libtomcrypt-1.17-25.el7.x86_64                                                                                                                      8/17
  Verifying  : python-cffi-1.6.0-5.el7.x86_64                                                                                                                      9/17
  Verifying  : python-ipaddress-1.0.16-2.el7.noarch                                                                                                               10/17
  Verifying  : python-enum34-1.0.4-1.el7.noarch                                                                                                                   11/17
  Verifying  : python2-pyasn1-0.1.9-7.el7.noarch                                                                                                                  12/17
  Verifying  : libtommath-0.42.0-5.el7.x86_64                                                                                                                     13/17
  Verifying  : python-paramiko-2.1.1-0.2.el7.noarch                                                                                                               14/17
  Verifying  : python2-jmespath-0.9.0-1.el7.noarch                                                                                                                15/17
  Verifying  : python2-cryptography-1.7.2-1.el7_4.1.x86_64                                                                                                        16/17
  Verifying  : python2-crypto-2.6.1-13.el7.x86_64                                                                                                                 17/17

Installed:
  ansible.noarch 0:2.4.2.0-1.el7

Dependency Installed:
  libtomcrypt.x86_64 0:1.17-25.el7               libtommath.x86_64 0:0.42.0-5.el7       python-cffi.x86_64 0:1.6.0-5.el7        python-enum34.noarch 0:1.0.4-1.el7
  python-httplib2.noarch 0:0.9.2-0.1.el7         python-idna.noarch 0:2.4-1.el7         python-ipaddress.noarch 0:1.0.16-2.el7  python-keyczar.noarch 0:0.71c-2.el7
  python-paramiko.noarch 0:2.1.1-0.2.el7         python-ply.noarch 0:3.4-11.el7         python-pycparser.noarch 0:2.14-1.el7    python2-crypto.x86_64 0:2.6.1-13.el7
  python2-cryptography.x86_64 0:1.7.2-1.el7_4.1  python2-jmespath.noarch 0:0.9.0-1.el7  python2-pyasn1.noarch 0:0.1.9-7.el7     sshpass.x86_64 0:1.06-1.el7

Complete!

========Check Ansible Version===================
[root@ip-172-31-44-223 ~]# ansible --version
ansible 2.6.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-2.6.0-py2.7.egg/ansible
  executable location = /bin/ansible
  python version = 2.7.5 (default, May  3 2017, 07:55:04) [GCC 4.8.5 20150623 (Red Hat 4.8.5-14)]
[root@ip-172-31-44-223 ~]#

===========================Pingtest==============================================================
[root@ip-172-31-44-223 ~]# ansible localhost -m ping
 [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all'

localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[root@ip-172-31-44-223 ~]# ansible localhost -m ping
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}


=====================Localhost entry====================
[root@ip-172-31-44-223 ~]# cat /etc/ansible/hosts
# This is the default ansible 'hosts' file.
#
# It should live in /etc/ansible/hosts
#
#   - Comments begin with the '#' character
#   - Blank lines are ignored
#   - Groups of hosts are delimited by [header] elements
#   - You can enter hostnames or ip addresses
#   - A hostname/ip can be a member of multiple groups

# Ex 1: Ungrouped hosts, specify before any group headers.
[localserver]
#localhost ansible_user=root ansible_password=qwerty
172.31.44.223