All installations are done on CentOS-7
Installation and Configuration
+--------------------------------------------------------------------+
¦ • MobaXterm 11.1 • ¦
¦ (SSH client, X-server and networking tools) ¦
¦ ¦
¦ ? SSH session to saurav@192.168.116.3 ¦
¦ • SSH compression : ? ¦
¦ • SSH-browser : ? ¦
¦ • X11-forwarding : ? (remote display is forwarded through SSH) ¦
¦ • DISPLAY : ? (automatically set on remote server) ¦
¦ ¦
¦ ? For more info, ctrl+click on help or visit our website ¦
+--------------------------------------------------------------------+
Last login: Tue Aug 17 18:37:23 2021 from 192.168.116.1
[saurav@saurav-vm1 ~]$ sudo su
[sudo] password for saurav:
[root@saurav-vm1 saurav]# useradd ansadmin
^[[A[root@saurav-vm1 saurav]# passwd ansadmin
Changing password for user ansadmin.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
[root@saurav-vm1 saurav]#
[root@saurav-vm1 saurav]# visudo
[root@saurav-vm1 saurav]# su - ansadmin
[ansadmin@saurav-vm1 ~]$ sudo su
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for ansadmin:
[root@saurav-vm1 ansadmin]# su - ansadmin
Last login: Mon Aug 30 04:52:38 EDT 2021 on pts/0
[ansadmin@saurav-vm1 ~]$ clear
[ansadmin@saurav-vm1 ~]$ ll
total 0
[ansadmin@saurav-vm1 ~]$ key-gen
bash: key-gen: command not found...
[ansadmin@saurav-vm1 ~]$ pwd
/home/ansadmin
[ansadmin@saurav-vm1 ~]$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ansadmin/.ssh/id_rsa):
Created directory '/home/ansadmin/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/ansadmin/.ssh/id_rsa.
Your public key has been saved in /home/ansadmin/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:u1gZr07kGP5V0bsj7VZ9/DsTQM4dL41/FTS3w4NmRjE ansadmin@saurav-vm1
The key's randomart image is:
+---[RSA 2048]----+
| Eoo.|
| .o+o+|
| ==oB+|
| +=oo*|
| . S . o+o|
| . = = . . oB|
| o * o . +.=|
| = + o.+.|
| ..= ...+|
+----[SHA256]-----+
[ansadmin@saurav-vm1 ~]$ ssh-copy-id 192.168.116.4
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ansadmin/.ssh/id_rsa.pub"
The authenticity of host '192.168.116.4 (192.168.116.4)' can't be established.
ECDSA key fingerprint is SHA256:5z0x/GQo8cqdU1eDt6H6fLDtVDK4Bp78PTDYu1Kj1hM.
ECDSA key fingerprint is MD5:8a:a7:f1:08:0f:43:89:89:64:b7:43:d9:5a:56:06:71.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ansadmin@192.168.116.4's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.116.4'"
and check to make sure that only the key(s) you wanted were added.
[ansadmin@saurav-vm1 ~]$ ssh-copy-id 192.168.116.5
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ansadmin/.ssh/id_rsa.pub"
The authenticity of host '192.168.116.5 (192.168.116.5)' can't be established.
ECDSA key fingerprint is SHA256:5z0x/GQo8cqdU1eDt6H6fLDtVDK4Bp78PTDYu1Kj1hM.
ECDSA key fingerprint is MD5:8a:a7:f1:08:0f:43:89:89:64:b7:43:d9:5a:56:06:71.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ansadmin@192.168.116.5's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.116.5'"
and check to make sure that only the key(s) you wanted were added.
[ansadmin@saurav-vm1 ~]$ ssh-copy-id 192.168.116.6
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ansadmin/.ssh/id_rsa.pub"
The authenticity of host '192.168.116.6 (192.168.116.6)' can't be established.
ECDSA key fingerprint is SHA256:5z0x/GQo8cqdU1eDt6H6fLDtVDK4Bp78PTDYu1Kj1hM.
ECDSA key fingerprint is MD5:8a:a7:f1:08:0f:43:89:89:64:b7:43:d9:5a:56:06:71.
Are you sure you want to continue connecting (yes/no)? yes
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
ansadmin@192.168.116.6's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh '192.168.116.6'"
and check to make sure that only the key(s) you wanted were added.
[ansadmin@saurav-vm1 ~]$ ssh 192.168.116.4
Last login: Mon Aug 30 14:22:21 2021
[ansadmin@saurav-vm2 ~]$ logout
Connection to 192.168.116.4 closed.
[ansadmin@saurav-vm1 ~]$ ssh 192.168.116.5
Last login: Mon Aug 30 14:22:05 2021
[ansadmin@saurav-vm3 ~]$ logout
Connection to 192.168.116.5 closed.
[ansadmin@saurav-vm1 ~]$ ssh 192.168.116.6
Last login: Mon Aug 30 04:51:44 2021
[ansadmin@saurav-vm1 ~]$ logout
Connection to 192.168.116.6 closed.
[ansadmin@saurav-vm1 ~]$ less ifconfig
ifconfig: No such file or directory
[ansadmin@saurav-vm1 ~]$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
ether 08:00:27:6e:af:04 txqueuelen 1000 (Ethernet)
RX packets 209 bytes 19529 (19.0 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.116.3 netmask 255.255.255.0 broadcast 192.168.116.255
inet6 fe80::ab0f:5e2:b4f0:4027 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:9f:6f:4b txqueuelen 1000 (Ethernet)
RX packets 1563 bytes 164604 (160.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1173 bytes 179989 (175.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s9: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.4.15 netmask 255.255.255.0 broadcast 10.0.4.255
inet6 fe80::2f02:d53b:7a97:ac9a prefixlen 64 scopeid 0x20<link>
ether 08:00:27:c6:6a:ad txqueuelen 1000 (Ethernet)
RX packets 70 bytes 7288 (7.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 105 bytes 11173 (10.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:aa:c7:d3 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[ansadmin@saurav-vm1 ~]$ sudo yum install -y ansible
[sudo] password for ansadmin:
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink | 6.0 kB 00:00:00
* base: centos.mirrors.estointernet.in
* epel: my.mirrors.thegigabit.com
* extras: centos.mirrors.estointernet.in
* updates: centos.mirrors.estointernet.in
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/3): updates/7/x86_64/primary_db | 9.6 MB 00:00:03
(2/3): epel/x86_64/updateinfo | 1.0 MB 00:00:07
(3/3): epel/x86_64/primary_db | 6.9 MB 00:00:09
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.9.25-1.el7 will be installed
--> Processing Dependency: python-httplib2 for package: ansible-2.9.25-1.el7.noarch
--> Processing Dependency: python-jinja2 for package: ansible-2.9.25-1.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.9.25-1.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.9.25-1.el7.noarch
--> Processing Dependency: sshpass for package: ansible-2.9.25-1.el7.noarch
--> Running transaction check
---> Package python-jinja2.noarch 0:2.7.2-4.el7 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-4.el7.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-4.el7.noarch
---> Package python-paramiko.noarch 0:2.1.1-9.el7 will be installed
---> Package python2-httplib2.noarch 0:0.18.1-3.el7 will be installed
---> Package python2-jmespath.noarch 0:0.9.4-2.el7 will be installed
---> Package sshpass.x86_64 0:1.06-2.el7 will be installed
--> Running transaction check
---> Package python-babel.noarch 0:0.9.6-8.el7 will be installed
---> Package python-markupsafe.x86_64 0:0.11-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================================================================================================
Package Arch Version Repository Size
==========================================================================================================================================================================================
Installing:
ansible noarch 2.9.25-1.el7 epel 17 M
Installing for dependencies:
python-babel noarch 0.9.6-8.el7 base 1.4 M
python-jinja2 noarch 2.7.2-4.el7 base 519 k
python-markupsafe x86_64 0.11-10.el7 base 25 k
python-paramiko noarch 2.1.1-9.el7 base 269 k
python2-httplib2 noarch 0.18.1-3.el7 epel 125 k
python2-jmespath noarch 0.9.4-2.el7 epel 41 k
sshpass x86_64 1.06-2.el7 extras 21 k
Transaction Summary
==========================================================================================================================================================================================
Install 1 Package (+7 Dependent packages)
Total download size: 19 M
Installed size: 113 M
Downloading packages:
(1/8): python-paramiko-2.1.1-9.el7.noarch.rpm | 269 kB 00:00:00
(2/8): python-babel-0.9.6-8.el7.noarch.rpm | 1.4 MB 00:00:01
(3/8): python-markupsafe-0.11-10.el7.x86_64.rpm | 25 kB 00:00:01
(4/8): sshpass-1.06-2.el7.x86_64.rpm | 21 kB 00:00:00
(5/8): python2-jmespath-0.9.4-2.el7.noarch.rpm | 41 kB 00:00:01
(6/8): python2-httplib2-0.18.1-3.el7.noarch.rpm | 125 kB 00:00:03
(7/8): python-jinja2-2.7.2-4.el7.noarch.rpm | 519 kB 00:00:07
(8/8): ansible-2.9.25-1.el7.noarch.rpm | 17 MB 00:00:11
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.6 MB/s | 19 MB 00:00:12
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : sshpass-1.06-2.el7.x86_64 1/8
Installing : python2-httplib2-0.18.1-3.el7.noarch 2/8
Installing : python-babel-0.9.6-8.el7.noarch 3/8
Installing : python2-jmespath-0.9.4-2.el7.noarch 4/8
Installing : python-paramiko-2.1.1-9.el7.noarch 5/8
Installing : python-markupsafe-0.11-10.el7.x86_64 6/8
Installing : python-jinja2-2.7.2-4.el7.noarch 7/8
Installing : ansible-2.9.25-1.el7.noarch 8/8
Verifying : python-markupsafe-0.11-10.el7.x86_64 1/8
Verifying : python-paramiko-2.1.1-9.el7.noarch 2/8
Verifying : python2-jmespath-0.9.4-2.el7.noarch 3/8
Verifying : python-babel-0.9.6-8.el7.noarch 4/8
Verifying : ansible-2.9.25-1.el7.noarch 5/8
Verifying : python2-httplib2-0.18.1-3.el7.noarch 6/8
Verifying : sshpass-1.06-2.el7.x86_64 7/8
Verifying : python-jinja2-2.7.2-4.el7.noarch 8/8
Installed:
ansible.noarch 0:2.9.25-1.el7
Dependency Installed:
python-babel.noarch 0:0.9.6-8.el7 python-jinja2.noarch 0:2.7.2-4.el7 python-markupsafe.x86_64 0:0.11-10.el7 python-paramiko.noarch 0:2.1.1-9.el7
python2-httplib2.noarch 0:0.18.1-3.el7 python2-jmespath.noarch 0:0.9.4-2.el7 sshpass.x86_64 0:1.06-2.el7
Complete!
[ansadmin@saurav-vm1 ~]$ ansible --version
ansible 2.9.25
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/home/ansadmin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /bin/ansible
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
[ansadmin@saurav-vm1 ~]$
[ansadmin@saurav-vm1 ~]$
[ansadmin@saurav-vm1 ~]$ python --version
Python 2.7.5
[ansadmin@saurav-vm1 ~]$
[ansadmin@saurav-vm1 ~]$ vi /etc/ansible/hosts
[ansadmin@saurav-vm1 ~]$ cat /etc/ansible/hosts|tail -10
# Here's another example of host ranges, this time there are no
# leading 0s:
## db-[99:101]-node.example.com
192.168.116.4
192.168.116.5
192.168.116.6
[ansadmin@saurav-vm1 ~]$
[ansadmin@saurav-vm1 ~]$ ansible all -m ping
192.168.116.6 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.116.5 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
192.168.116.4 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}