Reputation: 31
I am trying to play my first playbook on the new local machine. I have lost my previous one, so I am not able to look into it's configuration files. I have prepared two virtual machines for testing Ansible. The first one is an Ansible machine with whole config and playbooks, etc. The second one is the machine on which I want to make changes with playbook.
I've got the error: No inventory was parsed, only implicit localhost is available, but I declare inventory file in the command line:
ansible-playbook -i inventory/dockers.yml yum-update.yml
I read in Ansible documentation that config in /etc/ansible shouldn't be taken into consideration, because I used the -i option during command execution.
This is my inventory file. I believe that there must be something there, but I can't see it:
all:
hosts:
machine02:
ansible_host: 192.168.1.16
yumek:
hosts:
machine02:
vars:
ansible_user: test
remote_user: root
The output of the [ansible1@host01 ~]$ ansible-inventory --list is
:
[WARNING]: * Failed to parse /etc/ansible/hosts with yaml plugin: Parsed empty YAML file
[WARNING]: * Failed to parse /etc/ansible/hosts with constructed plugin: /etc/ansible/hosts is empty
[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
{
"_meta": {
"hostvars": {}
},
"all": {
"children": [
"ungrouped"
]
}
}
Thanks in advance.
Upvotes: 0
Views: 6696
Reputation: 31
I played playbook with option -i from $HOME location of non-root user, despite that Ansible did not use indicated inventory.
Solution was very simple, just changing inventory location path in the main config /etc/ansible/ansible.cfg on root account to:
inventory = ~/inventory_folder
Unfortunately, still I do not know why Ansible did not respect -i option in the command.
Upvotes: 3