When I try to create ansible host file as follows:
sudo vi /usr/local/etc/ansible/hosts
When I try to save the file I get following error:
"/usr/local/etc/ansible/hosts" E212: Can't open file for writing
Run:
$ sudo touch /usr/local/etc/ansible/hosts
$ sudo vi /usr/local/etc/ansible/hosts
To create a file and then open it.
The issue was that the host file did not exist. So, first I created the host file at the location: /usr/local/etc/ansible/hosts Then after that i could add the hosts to this file.
ls -lah /usr/local/etc/ansible/hosts
and also what user are you running ansible with?