Repository: ansible/ansible

Issue:
ansible failed to load yaml inventory plugin, loading ini plugin instead.
##### SUMMARY
ansible failed to load yaml inventory plugin, loading ini plugin instead.

##### ISSUE TYPE
 - Bug Report

##### COMPONENT NAME
ansible inventory

##### ANSIBLE VERSION
```
ansible 2.6.0
  config file = None
  configured module search path = ['/home/vadim/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib64/python3.6/site-packages/ansible
  executable location = /usr/lib/python-exec/python3.6/ansible
  python version = 3.6.5 (default, Jun 26 2018, 09:45:54) [GCC 7.3.0]
```

##### CONFIGURATION
None

##### OS / ENVIRONMENT
Linux

##### STEPS TO REPRODUCE

<!--- Paste example playbooks or commands between quotes below -->
```bash
ansible-inventory -vvv -i inventory/ --graph

```
Note that inventory is a folder with hosts.yaml, group_vars and host_vars in it.
If I run it like this:
```
ansible-inventory -vvv -i inventory/hosts.yaml --graph
```
it works as expected.

##### EXPECTED RESULTS
<!--- What did you expect to happen when running the steps above? -->
```
ansible-inventory -vvv -i inventory/ --graph
ansible-inventory 2.6.0
  config file = None
  configured module search path = ['/home/vadim/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib64/python3.6/site-packages/ansible
  executable location = /usr/lib/python-exec/python3.6/ansible-inventory
  python version = 3.6.5 (default, Jun 26 2018, 09:45:54) [GCC 7.3.0]
No config file found; using defaults
Parsed inventory/hosts.yaml inventory source with yaml plugin
```

##### ACTUAL RESULTS
<!--- What actually happened? If possible run with extra verbosity (-vvvv) -->

<!--- Paste verbatim command output between quotes below -->
```
ansible-inventory -vvv -i inventory/ --graph
ansible-inventory 2.6.0
  config file = None
  configured module search path = ['/home/vadim/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib64/python3.6/site-packages/ansible
  executable location = /usr/lib/python-exec/python3.6/ansible-inventory
  python version = 3.6.5 (default, Jun 26 2018, 09:45:54) [GCC 7.3.0]
No config file found; using defaults
Parsed inventory/hosts.yaml inventory source with ini plugin
```



Discussion:
Files identified in the description:
* [contrib/inventory/abiquo.ini](https://github.com/ansible/ansible/blob/devel/contrib/inventory/abiquo.ini)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
Can you provide an example of your YAML inventory file?  One that reproduces this behavior.

Also can you provide the output of:

```
ansible-config dump | grep INVENTORY_ENABLED
```

needs_info
```
 [WARNING]:  * Failed to parse /workdir/inventory/production/hosts.yml with ini plugin: b'/workdir/inventory/production/hosts.yml':4: Expected key=value host variable assignment, got: 100.100.100.100
```
the inventory is correct and works with 2.5.5: 
```
all:
  hosts:
    droplet:
      ansible_host: 100.100.100.100
      ansible_user: root
    server:
      ansible_host: 100.100.100.100
      ansible_user: root
```

```
bash-4.4# ansible-config dump | grep INVENTORY_ENABLED
INVENTORY_ENABLED(default) = ['host_list', 'script', 'yaml', 'ini', 'auto']
```

If I put the filename in -i flag, works fine:
```
ansible-playbook -i inventory/production/hosts.yml site.yml -vvvv
```
But if I only put the path, don't work:
```
ansible-playbook -i inventory/production/ site.yml -vvvv
```

This was introduced in https://github.com/ansible/ansible/commit/e707e71ec52

I've started a fix in https://github.com/ansible/ansible/pull/42475

Resolving patch:
diff --git a/lib/ansible/inventory/manager.py b/lib/ansible/inventory/manager.py
--- a/lib/ansible/inventory/manager.py
+++ b/lib/ansible/inventory/manager.py
@@ -259,7 +259,7 @@ def parse_source(self, source, cache=False):
 
                 # initialize and figure out if plugin wants to attempt parsing this file
                 try:
-                    plugin_wants = bool(plugin.verify_file(source))
+                    plugin_wants = bool(plugin.verify_file(to_text(source)))
                 except Exception:
                     plugin_wants = False
 


Test patch: