1

Continuig with my ansible learning, I already fixed how to Ansible: How to parse an inventory source but now I ran into a new problem. He executes the following 2 commands (but im not sure if he does as a normal user or root):

ssh-add -L

ssh-add ~/.ssh/id_rsa

And then he executes the following one, in order to do a ping to one of the 3 linux containers:

ansible 192.168.122.117 -m ping -u root

And then he gets a success ping message. But in my case, I get an error message that follows:

[smartinez@localhost ansible_course]$ ansible 192.168.122.117 -m ping -u root 192.168.122.117 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.122.117 port 22: No route to host\r\n", "unreachable": true }

I am not sure if I need to create another ssh rsa key only for ansible? Or if he is running the commands as root, and I need to create an ssh rsa for the root user?

I already tried running the 2 ssh-add commands as root but i got: "No such file or directory"

Also, I tried adding -k at the end with both users root and ubuntu, but the result us the same.

Any comment ans suggestion will be appreciated.

Regards

  • Your host 192.168.122.117 doesn't exist. Is it a VM? Is the VM booted? – jordanm Jul 27 '18 at 3:30
  • hi, thanks for your help, it is a linux container, I created 3 of them, all ubuntu. Their ips are the following: [allservers] 192.168.122.117 192.168.122.146 192.168.122.14. Also those ips are in a file called inventory – grimmjow_sms Jul 27 '18 at 3:33
  • (Could you either edit Qs to mention that the video is not public (paid for?), or include a link to the video?). I don't have a quick checklist for server network troubleshooting, but I can suggest generic steps. Starting inside the linux container: I assume you configured it to cover all the basic network settings, including a route to the internet (a.k.a. "default route" / "default router" / "default gateway"). What is the address of its default router? Can it successfully ping it? If you don't get a ping reply, but there's a good entry for it in ip -4 neigh, that might be ok as well. – sourcejedi Jul 31 '18 at 17:18
  • OH - but first. Before, you said you could login into the containers. Should I assume you meant something like lxc-console? Or, do you have normal ssh working OK, but for some mysterious-seeming reason, ansible is not able to connect? – sourcejedi Jul 31 '18 at 17:21
  • To be clear: "No route to host" is network troubleshooting territory. That error needs fixing first, and it does not have to do with any of your SSH keys. Of course sometimes the problem to fix is I wrote the wrong IP address somewhere :-). – sourcejedi Jul 31 '18 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.