getting error [WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

Hi i installed Ansible on MacOS and getting below errors

ansible all -m ping

[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’

ansible --version

ansible 2.7.0

config file = None

configured module search path = [‘/Users/bhaktavar_baba/.ansible/plugins/modules’, ‘/usr/share/ansible/plugins/modules’]

ansible python module location = /usr/local/Cellar/ansible/2.7.0/libexec/lib/python3.7/site-packages/ansible

executable location = /usr/local/bin/ansible

python version = 3.7.0 (default, Oct 25 2018, 15:05:47) [Clang 10.0.0 (clang-1000.11.45.2)]

But when i check /etc/ansible/hosts getting below error. Is it something wrong with installation procedure i followed?

ls -l /etc/ansible/hosts

ls: /etc/ansible/hosts: No such file or directory

The pip method of installation doesn’t not create the /etc/ansible nor any default files that go there.

OS packages will often do so.

This is not a problem, that just happens to be a default place to look for a things, but you can configure other paths using an ansible.cfg file or via the CLI, or create those paths/files yourself.