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
3,753 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
• 7,340 points

Related Questions In Ansible

+1 vote
2 answers

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 14, 2018 in Ansible by DareDev
• 6,890 points
2,136 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,439 views
+2 votes
1 answer
+1 vote
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
• 7,340 points
6,467 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP