ansible client

[root@localhost ~]# yum install ansible* openssh*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.hbcse.tifr.res.in
 * extras: centos.hbcse.tifr.res.in
 * updates: centos.hbcse.tifr.res.in
base                                                            | 3.6 kB  00:00:00   
extras                                                          | 3.4 kB  00:00:00   
updates                                                         | 3.4 kB  00:00:00   
Package openssh-server-7.4p1-16.el7.x86_64 already installed and latest version
Package openssh-7.4p1-16.el7.x86_64 already installed and latest version
Package openssh-clients-7.4p1-16.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.4.2.0-2.el7 will be installed
--> Processing Dependency: sshpass for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python2-jmespath for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-passlib for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-paramiko for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-jinja2 for package: ansible-2.4.2.0-2.el7.noarch
--> Processing Dependency: python-httplib2 for package: ansible-2.4.2.0-2.el7.noarch
---> Package ansible-doc.noarch 0:2.4.2.0-2.el7 will be installed
---> Package openssh-askpass.x86_64 0:7.4p1-16.el7 will be installed
---> Package openssh-cavs.x86_64 0:7.4p1-16.el7 will be installed
---> Package openssh-keycat.x86_64 0:7.4p1-16.el7 will be installed
---> Package openssh-ldap.x86_64 0:7.4p1-16.el7 will be installed
---> Package openssh-server-sysvinit.x86_64 0:7.4p1-16.el7 will be installed
--> Running transaction check
---> Package python-httplib2.noarch 0:0.9.2-1.el7 will be installed
---> Package python-jinja2.noarch 0:2.7.2-3.el7_6 will be installed
--> Processing Dependency: python-babel >= 0.8 for package: python-jinja2-2.7.2-3.el7_6.noarch
--> Processing Dependency: python-markupsafe for package: python-jinja2-2.7.2-3.el7_6.noarch
---> Package python-paramiko.noarch 0:2.1.1-9.el7 will be installed
---> Package python-passlib.noarch 0:1.6.5-2.el7 will be installed
---> Package python2-jmespath.noarch 0:0.9.0-3.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.4.2.0-2.el7          extras        7.6 M
 ansible-doc                   noarch       2.4.2.0-2.el7          extras        763 k
 openssh-askpass               x86_64       7.4p1-16.el7           base           76 k
 openssh-cavs                  x86_64       7.4p1-16.el7           base          229 k
 openssh-keycat                x86_64       7.4p1-16.el7           base           96 k
 openssh-ldap                  x86_64       7.4p1-16.el7           base          112 k
 openssh-server-sysvinit       x86_64       7.4p1-16.el7           base           71 k
Installing for dependencies:
 python-babel                  noarch       0.9.6-8.el7            base          1.4 M
 python-httplib2               noarch       0.9.2-1.el7            extras        115 k
 python-jinja2                 noarch       2.7.2-3.el7_6          updates       518 k
 python-markupsafe             x86_64       0.11-10.el7            base           25 k
 python-paramiko               noarch       2.1.1-9.el7            updates       269 k
 python-passlib                noarch       1.6.5-2.el7            extras        488 k
 python2-jmespath              noarch       0.9.0-3.el7            extras         39 k
 sshpass                       x86_64       1.06-2.el7             extras         21 k

Transaction Summary
=======================================================================================
Install  7 Packages (+8 Dependent packages)

Total download size: 12 M
Installed size: 53 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/base/packages/openssh-askpass-7.4p1-16.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for openssh-askpass-7.4p1-16.el7.x86_64.rpm is not installed
(1/15): openssh-askpass-7.4p1-16.el7.x86_64.rpm                 |  76 kB  00:00:00   
(2/15): openssh-keycat-7.4p1-16.el7.x86_64.rpm                  |  96 kB  00:00:00   
(3/15): openssh-cavs-7.4p1-16.el7.x86_64.rpm                    | 229 kB  00:00:00   
(4/15): openssh-ldap-7.4p1-16.el7.x86_64.rpm                    | 112 kB  00:00:00   
Public key for ansible-doc-2.4.2.0-2.el7.noarch.rpm is not installed
(5/15): ansible-doc-2.4.2.0-2.el7.noarch.rpm                    | 763 kB  00:00:00   
(6/15): python-httplib2-0.9.2-1.el7.noarch.rpm                  | 115 kB  00:00:00   
(7/15): python-babel-0.9.6-8.el7.noarch.rpm                     | 1.4 MB  00:00:01   
Public key for python-jinja2-2.7.2-3.el7_6.noarch.rpm is not installed
(8/15): python-jinja2-2.7.2-3.el7_6.noarch.rpm                  | 518 kB  00:00:01   
(9/15): python-markupsafe-0.11-10.el7.x86_64.rpm                |  25 kB  00:00:00   
(10/15): python-paramiko-2.1.1-9.el7.noarch.rpm                 | 269 kB  00:00:00   
(11/15): python2-jmespath-0.9.0-3.el7.noarch.rpm                |  39 kB  00:00:00   
(12/15): sshpass-1.06-2.el7.x86_64.rpm                          |  21 kB  00:00:00   
(13/15): python-passlib-1.6.5-2.el7.noarch.rpm                  | 488 kB  00:00:00   
(14/15): openssh-server-sysvinit-7.4p1-16.el7.x86_64.rpm        |  71 kB  00:00:02   
(15/15): ansible-2.4.2.0-2.el7.noarch.rpm                       | 7.6 MB  00:00:04   
---------------------------------------------------------------------------------------
Total                                                     2.6 MB/s |  12 MB  00:04   
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-5.1804.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-httplib2-0.9.2-1.el7.noarch                                 1/15
  Installing : sshpass-1.06-2.el7.x86_64                                          2/15
  Installing : python-paramiko-2.1.1-9.el7.noarch                                 3/15
  Installing : python-babel-0.9.6-8.el7.noarch                                    4/15
  Installing : python2-jmespath-0.9.0-3.el7.noarch                                5/15
  Installing : python-passlib-1.6.5-2.el7.noarch                                  6/15
  Installing : python-markupsafe-0.11-10.el7.x86_64                               7/15
  Installing : python-jinja2-2.7.2-3.el7_6.noarch                                 8/15
  Installing : ansible-2.4.2.0-2.el7.noarch                                       9/15
  Installing : openssh-server-sysvinit-7.4p1-16.el7.x86_64                       10/15
  Installing : openssh-askpass-7.4p1-16.el7.x86_64                               11/15
  Installing : openssh-cavs-7.4p1-16.el7.x86_64                                  12/15
  Installing : openssh-ldap-7.4p1-16.el7.x86_64                                  13/15
  Installing : openssh-keycat-7.4p1-16.el7.x86_64                                14/15
  Installing : ansible-doc-2.4.2.0-2.el7.noarch                                  15/15
  Verifying  : python-markupsafe-0.11-10.el7.x86_64                               1/15
  Verifying  : ansible-doc-2.4.2.0-2.el7.noarch                                   2/15
  Verifying  : python-passlib-1.6.5-2.el7.noarch                                  3/15
  Verifying  : openssh-keycat-7.4p1-16.el7.x86_64                                 4/15
  Verifying  : python2-jmespath-0.9.0-3.el7.noarch                                5/15
  Verifying  : openssh-ldap-7.4p1-16.el7.x86_64                                   6/15
  Verifying  : python-babel-0.9.6-8.el7.noarch                                    7/15
  Verifying  : ansible-2.4.2.0-2.el7.noarch                                       8/15
  Verifying  : python-paramiko-2.1.1-9.el7.noarch                                 9/15
  Verifying  : openssh-cavs-7.4p1-16.el7.x86_64                                  10/15
  Verifying  : python-jinja2-2.7.2-3.el7_6.noarch                                11/15
  Verifying  : sshpass-1.06-2.el7.x86_64                                         12/15
  Verifying  : python-httplib2-0.9.2-1.el7.noarch                                13/15
  Verifying  : openssh-askpass-7.4p1-16.el7.x86_64                               14/15
  Verifying  : openssh-server-sysvinit-7.4p1-16.el7.x86_64                       15/15

Installed:
  ansible.noarch 0:2.4.2.0-2.el7                  ansible-doc.noarch 0:2.4.2.0-2.el7 
  openssh-askpass.x86_64 0:7.4p1-16.el7           openssh-cavs.x86_64 0:7.4p1-16.el7 
  openssh-keycat.x86_64 0:7.4p1-16.el7            openssh-ldap.x86_64 0:7.4p1-16.el7 
  openssh-server-sysvinit.x86_64 0:7.4p1-16.el7 

Dependency Installed:
  python-babel.noarch 0:0.9.6-8.el7         python-httplib2.noarch 0:0.9.2-1.el7     
  python-jinja2.noarch 0:2.7.2-3.el7_6      python-markupsafe.x86_64 0:0.11-10.el7   
  python-paramiko.noarch 0:2.1.1-9.el7      python-passlib.noarch 0:1.6.5-2.el7     
  python2-jmespath.noarch 0:0.9.0-3.el7     sshpass.x86_64 0:1.06-2.el7             

Complete!
[root@localhost ~]# service sshd status
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-08-22 19:11:52 IST; 16min ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1150 (sshd)
    Tasks: 1
   CGroup: /system.slice/sshd.service
           └─1150 /usr/sbin/sshd -D

Aug 22 19:11:51 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
Aug 22 19:11:52 localhost.localdomain sshd[1150]: Server listening on 0.0.0.0 port 22.
Aug 22 19:11:52 localhost.localdomain sshd[1150]: Server listening on :: port 22.
Aug 22 19:11:52 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]#  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:sSaUwuen5CsBt8s7LKAsWwFW1zpzx+knuKr4rehepQg root@localhost.localdomain
The key's randomart image is:
+---[RSA 2048]----+
|   . ..          |
|  ...  o         |
|..  o = o .      |
|... .O . *       |
|E .o oB S        |
|o ..=o * o .     |
|oo.= oo . o      |
|oo= B  o         |
|=*.=+*o          |
+----[SHA256]-----+
[root@localhost ~]# ansible localhost -m ping
 [WARNING]: Could not match supplied host pattern, ignoring: all

 [WARNING]: provided hosts list is empty, only localhost is available

localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[root@localhost ~]# vi /etc/ansible/hosts

192.168.45.144

[root@localhost ~]# ifconfig

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.45.144  netmask 255.255.255.0  broadcast 192.168.45.255
        inet6 fe80::e9b6:a1b4:d2c0:6d7b  prefixlen 64  scopeid 0x20<link>
        inet6 fe80::e5da:5dbc:3974:b514  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ac:bb:81  txqueuelen 1000  (Ethernet)
        RX packets 9126  bytes 12814622 (12.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3415  bytes 216779 (211.6 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 64  bytes 5568 (5.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 64  bytes 5568 (5.4 KiB)
        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:40:25:4a  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

[root@localhost ~]# vi /etc/ansible/hosts

[root@localhost ~]# ssh-copy-id root@192.168.45.144
The authenticity of host '192.168.45.144 (192.168.45.144)' can't be established.
ECDSA key fingerprint is SHA256:m8YpYiq0v1ChLkZk74cRLvjYcNwbQaMMjGnVvdox/7U.
ECDSA key fingerprint is MD5:7a:50:34:05:30:55:60:58:77:33:80:ff:76:e9:f1:f3.
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.45.144's password:

Number of key(s) added: 1

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

[root@localhost ~]# ansible 192.168.45.144 -m ping
192.168.45.144 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

Comments

Popular posts from this blog

ansible redhat cluster qorum qdevice

PE 3.9.0 on centos 6

gfs2 cluster