ansible - Ansible ping 有效,但 ansible-playbook 收到“无法通过 ssh 连接到主机”
问题描述
当我 ping 所有可用的库存时,我遇到了这个问题:
ansible all -m ping --user ubuntu --private-key /path/to_key
它成功地ping通了他们
10.0.1.50 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
10.0.1.40 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python"
},
"changed": false,
"ping": "pong"
}
10.0.1.100 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
10.0.1.200 | SUCCESS => {
"ansible_facts": {
"discovered_interpreter_python": "/usr/bin/python3"
},
"changed": false,
"ping": "pong"
}
但是如果我尝试运行剧本
ansible-playbook system_info.yml --user ubuntu --private-key /path/to_key
我收到“无法通过 ssh 连接到主机:端口 22 关闭连接”,“无法访问”:true}
fatal: [10.0.1.200]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed by 10.0.1.200 port 22", "unreachable": true}
fatal: [10.0.1.40]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed by 10.0.1.40 port 22", "unreachable": true}
fatal: [10.0.1.50]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed by 10.0.1.50 port 22", "unreachable": true}
fatal: [10.0.1.100]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Connection closed by 10.0.1.100 port 22", "unreachable": true}
我错过了什么?
解决方案
我们验证了它ansible all -a hostname -m shell -u ubuntu --key-file=...
有效。我们了解到,选项必须在剧本之前指定:
ansible-playbook --user ubuntu --private-key /path/to_key system_info.yml
推荐阅读
- php - Echo Dropdown 的选项名称而不是它的值
- ios - 按下 uibutton 会导致 (lldb) 错误与 EXC_BAD_INSTRUCTION
- c++ - AVX指令中寄存器和指针的客观区别
- java - TestNG 设置测试状态
- d3.js - d3.js sankey diagram - 改变粒子密度和形状
- r - 在 R 中的数据框中创建列,显示渐进式计数
- java - 如何使用 Asynctask 将下载从主线程移动到后台线程
- javascript - 如何在 bash 中运行 JavaScript 文件
- scala - Scala Play 框架 POST 请求使用请求正文
- angular - 使用货币管道在离子输入上无法按预期工作