如何解决使用 ansible ping 时无法连接到服务器
我正在尝试使用 ansible ping 服务器
ansible -m ping all -vvv
我的主机文件路径是 anstest/hosts.txt,数据是
[servers]
10.4.74.15 ansible_user=scmuser
server1 ansible_host=10.167.70.15 ansible_ssh_user=muser ansible_ssh_pass=Cdjbfjk
[all:vars]
ansible_python_interpreter=/usr/bin/python
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method
Parsed /etc/ansible/hosts inventory source with ini plugin
Meta: ran handlers
<10.4.74.15> ESTABLISH SSH CONNECTION FOR USER: None
10.4.74.15 | UNREACHABLE! => {
"changed": false,"msg": "Failed to connect to the host via ssh:
尝试了很多..找不到解决方案
解决方法
Ansible 没有解析您指定的 SSH 用户,如您所见:
<10.4.74.15> ESTABLISH SSH CONNECTION FOR USER: None
这应该是:
<10.4.74.15> ESTABLISH SSH CONNECTION FOR USER: scmuser
Ansible 未使用您的清单文件中声明的 ansible_user
或 ansibe_ssh_user
。
检查您的清单文件并查找可能的错误,因为您粘贴中的日志条目表明 Ansible 对此不满意。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。