Reputation: 15871
hosts.ini
[local]
127.0.0.1 ansible_connection=local
hosts.yaml
local:
hosts:
127.0.0.1:
vars:
ansible_connection: local
then I run ansible local -m ping -i hosts.ini
I got expected ouput, then I run ansible local -m ping -i hosts.yaml
I got:
[WARNING]: * Failed to parse /home/elruso/projects/ansible/hosts.yaml with ini plugin: /home/elruso/projects/ansible/hosts.yaml:5: Expected key=value host variable assignment, got: local
[WARNING]: Unable to parse /home/elruso/projects/ansible/hosts.yaml as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: Could not match supplied host pattern, ignoring: local
[WARNING]: No hosts matched, nothing to do
According to docs I can use yaml files as inventory without problems. How can I specify to use the yml plugin?
$ansible --version
ansible 2.4.0.0
config file = /home/elruso/projects/ansible/ansible.cfg
configured module search path = ['/home/elruso/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/elruso/.virtualenvs/ansible/lib/python3.6/site-packages/ansible
executable location = /home/elruso/.virtualenvs/ansible/bin/ansible
python version = 3.6.2 (default, Jul 20 2017, 08:43:29) [GCC 5.4.1 20170519]
Update: issue opened
Upvotes: 2
Views: 10149
Reputation: 31
deleting the inventory file and recreating it on the ansible controller fixed it for me.
Upvotes: 0
Reputation: 11546
There's a bug in ansible 2.4.0 on python 3 (trying to find the .yml
bytes in a list of strings).
This bug has been fixed in this commit https://github.com/ansible/ansible/commit/72bdf7aa7e1b867380201092dff65338d59cd8fa, it may be released as 2.4.1.
Upvotes: 1
Reputation: 68469
The problem is reproducible in Python 3 and looks like a bug.
Use Python 2 instead of Python 3, as the latter is not officially supported yet.
Upvotes: 3