ansible 能顺利执行的前提是不是免密? /export/yhdfs/daily_check_...
Created on: January 8, 2026
Created on: January 8, 2026
ansible 能顺利执行的前提是不是免密?
/export/yhdfs/daily_check_new/bin/venv/lib/python2.7/site-packages/ansible/parsing/vault/init.py:44: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in the next release.
from cryptography.exceptions import InvalidSignature
10.194.17.10 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
10.194.17.11 | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
"unreachable": true
}
这种情况 是不是异常的?
简单结论先给你:
是的,在大多数“非交互式”场景下,Ansible 顺利执行的前提基本就是 SSH 免密(或至少是 Ansible 能自动拿到凭据)。
你贴出来的这种情况,对 Ansible 来说是异常的连接失败,不是正常执行状态。
下面分点说明。
严格说 不一定只能是免密,但必须满足一个条件:
Ansible 在执行时,不能卡在“需要人工输入密码”的地方
常见可行方式只有这几种:
不需要输入密码 → ✅ Ansible 最稳定
--ask-pass / --ask-become-pass
bashansible all -m ping --ask-pass
iniansible_ssh_pass=xxx
👉 生产环境 / 自动化检查脚本,基本都要求免密 SSH
核心错误是这一句:
textPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password)
这表示 Ansible 通过 SSH 连接目标主机时,所有尝试的认证方式都失败了:
所以 Ansible 直接判定:
json"unreachable": true
👉 在 Ansible 语义里,这就是“主机不可达”的异常状态
只要满足以下任意一条,就说明这是异常情况:
只有在这种情况下才算“符合预期”:
这些机器本来就没配置 SSH 免密,你只是临时试跑了一下 Ansible
textCryptographyDeprecationWarning: Python 2 is no longer supported
但要注意:
python2.7 + 老版本 ansible
👉 迟早会彻底跑不起来
建议(中长期):
在 Ansible 机器上,手动试一下:
👉 那 100% 是免密没配好
常见原因包括:
如果你愿意,可以把: