ansible自动化运维排错思路

[root@jump121 ~]# ansible pssh -m command -a 'uptime'
192.168.80.121 | FAILED | rc=-1 >>
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.
192.168.80.114 | FAILED | rc=-1 >>
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.
192.168.80.111 | FAILED | rc=-1 >>
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.
192.168.80.116 | CHANGED | rc=0 >>
 10:34:46 up  2:20,  3 users,  load average: 0.00, 0.00, 0.00

 

[root@jump121 ~]# ansible all -m ping
\192.168.80.111 | FAILED! => {
    "msg": "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."
}
192.168.80.121 | FAILED! => {
    "msg": "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."
}
192.168.80.114 | FAILED! => {
    "msg": "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."
}
^H192.168.80.116 | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": false,
    "ping": "pong"
}

 

解决方法:

使用ansible之前要做密钥认证

[root@jump121 ~]# ssh root@192.168.80.111
The authenticity of host '192.168.80.111 (192.168.80.111)' can't be established.
ED25519 key fingerprint is SHA256:InW2EeyfSJq7zUz+oYR9GtIZJz+tAsGr2U28uYylapo.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.80.111' (ED25519) to the list of known hosts.
root@192.168.80.111's password: 
Last login: Thu Mar 28 10:57:29 2024 from 192.168.80.88
[root@jump111 ~]# 
注销
Connection to 192.168.80.111 closed.
 

[root@jump121 ~]# ssh root@192.168.80.114
The authenticity of host '192.168.80.114 (192.168.80.114)' can't be established.
ED25519 key fingerprint is SHA256:FqMSYQgufsI/RkpAPv+S4X3Y3rdWdqCYYwW4mOfn99M.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.80.114' (ED25519) to the list of known hosts.
root@192.168.80.114's password: 
Last login: Thu Mar 28 10:55:45 2024 from 192.168.80.88
[root@jump114 ~]# 
注销
Connection to 192.168.80.114 closed.
[root@jump121 ~]# ansible all -m ping

  • 13
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值