Error message “Failed to connect to the host via ssh” while running ping command on host machines through Ansible

0 votes

I have been trying to connect to machines and run a ping command on nodes using ansible. I am getting the below message.

ansible -i inventory all -m ping

Error Message:

centosinstance | UNREACHABLE! => {
    "changed": false, 
    "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname centosinstance: Name or service not known\r\n", 
    "unreachable": true
}

I have also stated the private key file and the remote user name in ansible.cfg file.

Can anyone help me with this issue ?

Apr 25, 2018 in Ansible by Atul
• 10,240 points
344 views

1 answer to this question.

0 votes

Just go through the error message:

Ansible can't be able to resolve the centosinstance hostname. You just need to modify your inventory as :

centosinstance ansible_ssh_host=192.168.1.10
centosinstance1 ansible_ssh_host=192.168.1.11
Then, change the ip addresses with the ip addresses of your machines and try it one more time. I hope this time it will work.

answered Apr 25, 2018 by shubham
• 6,890 points

Related Questions In Ansible

0 votes
1 answer

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 13, 2018 in Ansible by DareDev
• 6,810 points
175 views
0 votes
1 answer
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,380 points
152 views
0 votes
1 answer
0 votes
3 answers
0 votes
1 answer

How do I execute a shell script and then use the result in ansible

This can work out for you: - name: ...READ MORE

answered Apr 11, 2018 in Ansible by shubham
• 6,890 points
777 views