Ansible: no hosts matched

Question:

I’m trying to execute my first remote shell script on Ansible. I’ve first generated and copied the SSH keys. Here is my yml file:

When launching the playbook however, the outcome is “no hosts matched”:

I’ve tried also using the host name (instead of the IP address), however nothing changed. Any help ?

Answer:

You need to define a host inventory.

The default path for this is /etc/ansible/hosts (as also stated by helloV).

For a minimal example you can also specify an inventory in the command line:

The trailing comma makes it a list, such that ansible parses it directy. Otherwise you can run

where myinventory is a file listing your hosts.

Leave a Reply