ansible 提示安装sshpass
之前用ansible一直用的root身份、机器之间又早早的做好了ssh信任、所以一直也没有出现什么问题。今天想想自己不能这么浪了,还是用回普通用户吧;
然而马上就遇到了第一个问题,ansible提示安装sshpass这个软件包。
一、ansible提示安装sshpass这个软件包:
ansible workstudio -m ping workstudio | FAILED! => { "failed": true, "msg": "to use the 'ssh' connection type with passwords, you must install the sshpass program" }
二、安装sshpass :
yum -y install sshpass Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * epel: mirrors.ustc.edu.cn Resolving Dependencies --> Running transaction check ---> Package sshpass.x86_64 0:1.06-1.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================== Package Arch Version Repository Size ============================================================================================================================== Installing: sshpass x86_64 1.06-1.el7 epel 21 k Transaction Summary ============================================================================================================================== Install 1 Package Total download size: 21 k Installed size: 38 k Downloading packages: warning: /var/cache/yum/x86_64/7/epel/packages/sshpass-1.06-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY Public key for sshpass-1.06-1.el7.x86_64.rpm is not installed sshpass-1.06-1.el7.x86_64.rpm | 21 kB 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-9.noarch (installed) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : sshpass-1.06-1.el7.x86_64 1/1 Verifying : sshpass-1.06-1.el7.x86_64 1/1 Installed: sshpass.x86_64 0:1.06-1.el7 Complete!
三、注意sshpass这个包并不在系统光盘里面,它是epel这人源中包涵的包
四、测试ansible是否可用了:
ansible workstudio -m ping workstudio | SUCCESS => { "changed": false, "ping": "pong" }
五、什么情况会出现要求安装sshpass:
如果在/etc/ansible/host 中配置的ssh登录用户使用的是密钥的认证是不会出现这个问题的;也就是说
1、在运行ansible的主机上要与被控机建立ssh信任。
2、在/etc/ansible/host文件中不要指ansible_ssh_pass这个变量,不然它就强制走密码认证了,而不是密钥。
----