主机 user@ip_address 的 Ansible“无法解析主机名”错误

Nik*_*aga 2 ssh ansible

在运行这个...

$ ansible all -m ping
Run Code Online (Sandbox Code Playgroud)

我得到这个...

[WARNING]: sftp transfer mechanism failed on [test@172.31.48.154]. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [test@172.31.48.154]. Use ANSIBLE_DEBUG=1 to see detailed information

test@172.31.48.154 | FAILED! => {
  "failed": true,
  "msg": "failed to transfer file to /home/test/.ansible/tmp/ansible-tmp-148610479.7-240708330710714/ping.py:\n\nssh: Could not resolve hostname 172.31.48.154]:Name or service not known\r\nlost connection\n"
}
localhost | SUCCESS => {
  "changed": false,
  "ping": "pong"
}
Run Code Online (Sandbox Code Playgroud)

Gri*_*vit 5

username@host清单中不支持使用。见问题#14255

相反,您可以编写您的库存文件,如:

host.example.com     ansible_connection=ssh        ansible_user=test
Run Code Online (Sandbox Code Playgroud)

或运行您的命令,如:

$ ansible all -m ping -u test
Run Code Online (Sandbox Code Playgroud)