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.
The Ansible project was cloned from here:
https://github.com/sebiwi/kubernetes-coreos
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.
I’m trying to follow the project author’s guide but I think he assumes readers are already familiar with Ansible.
https://blog.octo.com/en/how-does-it-work-kubernetes-episode-5-master-and-worker-at-last/#comment-632228
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.
This blacklist is defined by
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#inventory-ignore-exts
So when using
-i inventories/
that
vagrant.ini
is ignored, as opposed to explicitly listing that
vagrant.ini
as your inventory source.
Simply removing the
.ini
extension would allow the directory version to work.
is file /etc/ansible/hosts exist? perhaps you should create it first
sudo mkdir /etc/ansible/ sudo touch /etc/ansible/hosts sudo chmod 777 /etc/ansible/hosts sudo echo "localhost ansible_connection=local" >> /etc/ansible/hosts
best regards,
stifan
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
> 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.
James Cassell