02-12-2022 05:52 PM
Hi I have a question that is in my mind for a little long time. ansible/Ubuntu is intalled at vmware workstation. The Ubuntu can ping switches 192.168.10.10 without any issue. But before using command "ansible -m ping all" to ping the switch at the Ubuntu, we need to use the below commands to send key to switch 192.168.10.10. Looks like the ping has different path or machenism. but do not know how it work. Anyone can explain a little? Thank you
ssh-keygen -t rsa
ssh-copy-id 192.168.10.10
02-13-2022 06:40 AM
Hi
Something doesn´t make sense. The command "ssh-keygen -t rsa" ssh-copy-id 192.168.10.10 is used to access the swtich, or any device using SSH protocol.
"ansible -m ping all" in the other hand, is just an attempt to ping a bunch of devices on the network. They dont should have relationship.
02-13-2022 01:32 PM - edited 02-13-2022 01:33 PM
Thanks Flavio for your reply! I have the same exact question as you. It looks like it does not make sense. However both really have some relationship. People use it for ping to remote device from ansible/ubuntu successfully. It cannot work without it. Thats why i posted the question here. also below is example link:
02-13-2022 03:07 PM - edited 02-13-2022 03:07 PM
Hi
I got it. The reason is as follow. Actually, this is not a ping just like we are used to use in network. This is a small scritp that actually access the remote host and run a validation and get a responde. That´s why you need to use the Key gen before.
Features of the Ansible ping Module
The ping module is quite simple, and the following is a list of the features provided by this module:
Not an ICMP ping; rather, it is a small module that requires a valid Python environment on remote hosts.
Windows remote hosts should use the win_ping module instead.
Provides a net_ping module for network devices.
Accepts only a single parameter to raise an exception.
Used by default when calling the ansible command in the /usr/bin/ansible directory to verify login permissions and a valid Python environment.
Returns the string ‘pong’ on success.
02-15-2022 12:35 PM
Great! Very good explanation!
One more question, the command "ssh-copy-id 192.168.10.10" above is to send the key to server, if this is case, the below command has the same function?
ip ssh pubkey-chain
username xxxx
key-string
xyxyxyxyxyxyyx.........(public key)
exit
eixt
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide