How can I have my Ansible project use only the local /inventories directory? I am getting this output and I get the impression that Ansible is not finding my inventories.
`
[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’
[WARNING]: Could not match supplied host pattern, ignoring: kube-master
`
I’m new to Ansible and I’m confused that Ansible looks outside the project directory by default.
I see that other people who have reported this issue also installed with Homebrew, as I have, but I don’t yet see a clear solution.
Ah ha, looks like the command needs to begin with ansible -i inventories/vagrant.ini for this project. Other examples I was following use simply -i inventory, so it wasn’t clear to me that I need to reference this vagrant.ini file. I don’t understand why this project is setup this way. I would expect Ansible to default first any local inventory file, but today is the first day I’m using Ansible.
By default ansible ignores files with a .ini extension when using an inventory directory. This is due to many dynamic inventory scripts using a .ini extension for their configuration files.
is file /etc/ansible/hosts exist? perhaps you should create it first
e.g. sudo mkdir /etc/ansible/ sudo touch /etc/ansible/hosts sudo chmod 777 /etc/ansible/hosts sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts
also make sure that you are in the root directory while doing mkdir
>
> is file /etc/ansible/hosts exist? perhaps you should create it first
> e.g.
> sudo mkdir /etc/ansible/
> sudo touch /etc/ansible/hosts
> sudo chmod 777 /etc/ansible/hosts
Pretty sure that making the inventory executable will cause ansible to try to run it as a script then use the output as inventory.