# Ansible 2.2 YAML/INI error



## DutchDaemon (Nov 2, 2016)

Just saw a rather quirky error that took a bit of trial and error to get rid of. Just in case anyone Googles it:

```
ERROR! Attempted to read "/usr/local/etc/ansible/hosts" as YAML: Syntax Error while loading YAML.


The error appears to have been in '/usr/local/etc/ansible/hosts': line 15, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:


[all:vars]
    ^ here

Attempted to read "/usr/local/etc/ansible/hosts" as ini file: list index out of range
```
This is caused by comments with leading whitespace in the /usr/local/etc/ansible/hosts inventory file. This is new behavior for this Ansible version!

So if you're in the habit of writing something like this in that hosts file:
	
	



```
[web]
     # legacy servers
     webserver-[1:2].company.com
```
Change it into:
	
	



```
[web]
# legacy servers
     webserver-[1:2].company.com
```
or
	
	



```
[web]
     webserver-[1:2].company.com # legacy servers
```


----------

