0
votes

this is my hosts file

ansible_host=XX.XXX.xx.x ansible_port=9301

[all:vars]
ansible_python_interpreter=/usr/bin/python3

and my command is: ansible all -i hosts -m ping

and I keep getting:

ansible_host=xx.xxx.xxx.xx | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname ansible_host=xx.xxx.xxx.xx: Name or service not known", "unreachable": true }

1

1 Answers

0
votes

It appears, based solely upon your posted content, that you left off the inventory hostname; all of those key=value pairs, such as that ansible_host= part, are for assigning hostvars to an existing inventory hostname. You'll want an inventory file like this:

my-awesome-host ansible_host=XX.XXX.xx.x ansible_port=9301

In the future, you can confirm what ansible thinks about your inventory via the ansible-inventory command:

ansible-inventory -i ./your-inventory-file.ini --list