4

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
3
  • 1
    That error could be thrown if the file does not exists. According to this and this source the path to the hosts file is different.
    – 030
    Sep 11, 2017 at 19:35
  • 1
    please post the output of ls -lah /usr/local/etc/ansible/hosts and also what user are you running ansible with?
    – 13dimitar
    Sep 12, 2017 at 14:29
  • @030 thanks for the response it was helpful Sep 12, 2017 at 16:07

2 Answers 2

3

Run:

$ sudo touch /usr/local/etc/ansible/hosts
$ sudo vi /usr/local/etc/ansible/hosts

To create a file and then open it.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.