ansible不配ssh链接,用户密码登陆

 1 yum install -y ansible
 2 
 3 wget https://nchc.dl.sourceforge.net/project/sshpass/sshpass/1.06/sshpass-1.06.tar.gz
 4 tar -xzf sshpass-1.06.tar.gz
 5 cd sshpass-1.06
 6 ./configure
 7 make
 8 make install
 9 
10 #主配置文件 /etc/ansible/ansible.cfg
11 #受控主机清单 /etc/ansible/hosts
12 vim /etc/ansible/hosts
13     [common]
14     [api]
15     192.168.0.100
16     [web]
17     192.168.0.200
18     [common:children]
19     api
20     web
21     [common:vars]
22     ansible_ssh_user=dev
23     ansible_ssh_pass=123456
24     ansible_ssh_port=2222
25 
26 ansible api -a "ls /tmp/"
27 #1、出现错误:
28     192.168.0.100 | UNREACHABLE! => {
29         "changed": false, 
30         "msg": "Authentication or permission failure. In some cases, you may have been able to authenticate and did not have permissions on the target directory. Consider changing the remote tmp path in ansible.cfg to a path rooted in \"/tmp\". Failed command was: ( umask 77 && mkdir -p \"` echo /home/dev/.ansible/tmp/ansible-tmp-1545187395.08-192944776479178 `\" && echo ansible-tmp-1545187395.08-192944776479178=\"` echo /home/dev/.ansible/tmp/ansible-tmp-1545187395.08-192944776479178 `\" ), exited with result 1", 
31         "unreachable": true
32     }
33     #远程机子没有/home/dev/目录,补上便可
34 #2、出现错误:
35     192.168.0.100 | FAILED | rc=-1 >>
36     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.
37     #在/etc/ansible/ansible.cfg里打开 host_key_checking = False
38 
39 ansible api -a "ls /tmp/"
40     192.168.0.100 | SUCCESS | rc=0 >>
41     1.log
42     2.log

 

参考:html

https://www.cnblogs.com/iois/p/6230800.html?tdsourcetag=s_pctim_aiomsg
http://blog.51cto.com/13859004/2173972
https://blog.csdn.net/wmj2004/article/details/53216002
http://www.javashuo.com/article/p-xzlpobrl-v.html
https://blog.csdn.net/longxibendi/article/details/46989735web

相关文章
相关标签/搜索