El Ruso El Ruso - 3 years ago 344
Python Question

YAML inventory parsing error


[local] ansible_connection=local


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
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download