问题描述
我正在尝试使用 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 对此不满意。