Cant ping nodes via ssh

I’m trying to set upp ansible for a project with multiple Raspberry Pi’s. I created sshkey’s and copied them to my test node. I also made a host list. When i try to ping (ansible all -m ping) the node i keep getting the same errormsg:

SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh.

I know I can connect via ssh, because I did a test with ssh pi@ip_address. I also have to enter passphrase for id_rsa so i guess that means it recognizes the key on both ends?

When I run -vvvv it says:
ERROR! Missing target hosts

Anyway. If anybody came across this error before or know how I can solve it I would be greatfull.

  • First you must have a host file list, with the name of your differents raspberry:
    [server]
    raspberry1
    raspberry2
  • Save into hosts file name
    ansible-playbook -i hosts -l server (your ansible script)

(your ansible script)

  • hosts: all
    remote_user: root
    gather_facts: yes
    tasks:
  • ping:

Hi Jørgen,

By default, ansible uses the default host file specified @ /etc/hosts (I’m assuming you are using linux here). If you specified a separate host file, you need to tell ansible its location with the -i option.
Also, do you think you can share the content of your host file ? It has to be something like this : (the IP adress is fictive and for demonstration purposes only)

[group_name]
custom_hostname ansible_host=192.168.1.2

Or

[group_name]
192.168.1.2