# no hosts matched

**URL:** <https://forum.ansible.com/t/no-hosts-matched/32443>\
**Category:** Ansible Project\
**Created:** [March 11, 2020, 10:15am UTC](https://forum.ansible.com/t/no-hosts-matched/32443 "2020-03-11T10:15:11Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandy.hung](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sandy.hung](https://forum.ansible.com/u/sandy.hung)\
**Post date:** [March 11, 2020, 10:15am UTC](https://forum.ansible.com/t/no-hosts-matched/32443/1 "2020-03-11T10:15:11Z")

</div>

Dear all:

I have been normal before but this error message appeared in a few week

can you help me.  
thanks.

sandy@test-VirtualBox:~$ sudo ansible-playbook nfsclient.yml -i myinventory  
[WARNING]: Unable to parse /home/sandy/myinventory as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that  
the implicit localhost does not match ‘all’

PLAY [all] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
skipping: no hosts matched

my hosts

192.168.1.120 ansible\_user=sandy  
192.168.1.120 ansible\_sudo\_pass=‘xxxxxxx’  
192.168.1.120 ansible\_connection=local

---

<div class="post-metadata">

**Author:** ![Deepak\_Rohila](https://avatars.discourse-cdn.com/v4/letter/d/dec6dc/32.png) [@Deepak\_Rohila](https://forum.ansible.com/u/Deepak_Rohila)\
**Post date:** [March 11, 2020, 10:21am UTC](https://forum.ansible.com/t/no-hosts-matched/32443/2 "2020-03-11T10:21:00Z")

</div>

hi,  
can you remove me from this group asap.

---

<div class="post-metadata">

**Author:** ![Mark\_Whaite](https://avatars.discourse-cdn.com/v4/letter/m/9dc877/32.png) [@Mark\_Whaite](https://forum.ansible.com/u/Mark_Whaite)\
**Post date:** [March 11, 2020, 10:40am UTC](https://forum.ansible.com/t/no-hosts-matched/32443/3 "2020-03-11T10:40:03Z")

</div>

Hi Sandy

I think it is the ‘my hosts’ line. I would place that between . or remove it. I would also move the vars to a group ver. So something like this.

[my\_hosts]  
192.168.1.120

[my\_hosts:vars]  
ansible\_connection=local  
ansible\_sudo\_pass=‘xxxxxxx’  
ansible\_connection=local

---

<div class="post-metadata">

**Author:** ![vbotka](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/vbotka/32/359_2.png) [@vbotka](https://forum.ansible.com/u/vbotka)\
**Post date:** [March 11, 2020, 10:47am UTC](https://forum.ansible.com/t/no-hosts-matched/32443/4 "2020-03-11T10:47:10Z")

</div>

> sandy@test-VirtualBox:~$ sudo ansible-playbook nfsclient.yml -i myinventory  
> [...]  
> PLAY [all]  
> \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
> skipping: no hosts matched
> 
> my hosts  
> 192.168.1.120 ansible\_user=sandy  
> 192.168.1.120 ansible\_sudo\_pass='xxxxxxx'  
> 192.168.1.120 ansible\_connection=local

Create file "myinventory". See "How to build your inventor"  
[https://docs.ansible.com/ansible/latest/user\_guide/intro\_inventory.html](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html)

For example

> cat myinventory

192.168.1.120 ansible\_user=sandy ansible\_sudo\_pass='xxxxxxx'  
ansible\_connection=local

> ansible-inventory -i myinventory --list --vars

{  
&nbsp;&nbsp;&nbsp;&nbsp;"\_meta": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hostvars": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"192.168.1.120": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_connection": "local",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_sudo\_pass": "xxxxxxx",  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ansible\_user": "sandy"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;"all": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"children": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"ungrouped"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  
&nbsp;&nbsp;&nbsp;&nbsp;},  
&nbsp;&nbsp;&nbsp;&nbsp;"ungrouped": {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"hosts": [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"192.168.1.120"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;]  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

HTH,

&nbsp;&nbsp;-vlado

---

<div class="post-metadata">

**Author:** ![sandy.hung](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@sandy.hung](https://forum.ansible.com/u/sandy.hung)\
**Post date:** [March 12, 2020, 10:15am UTC](https://forum.ansible.com/t/no-hosts-matched/32443/5 "2020-03-12T10:15:48Z")

</div>

I change hosts, but still error connect.

[test]

192.168.1.120

[vars]

ansible\_user=sandy

ansible\_sudo\_pass=‘xxxxxxxx’

ansible 2.9.6

config file = /etc/ansible/ansible.cfg

configured module search path = [u’/home/sandy/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]

ansible python module location = /usr/lib/python2.7/dist-packages/ansible

executable location = /usr/bin/ansible

python version = 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 7.4.0]

Using /etc/ansible/ansible.cfg as config file

host\_list declined parsing /etc/ansible/hosts as it did not pass its verify\_file() method

[WARNING]: \* Failed to parse /etc/ansible/hosts with script plugin: problem

running /etc/ansible/hosts --list ([Errno 8] Exec format error)

File “/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py”, line 280, in parse\_source

plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)

File “/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/script.py”, line 161, in parse

raise AnsibleParserError(to\_native(e))

[WARNING]: \* Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error

while loading YAML. did not find expected The error appears

to be in ‘/etc/ansible/hosts’: line 48, column 1, but may be elsewhere in the

file depending on the exact syntax problem. The offending line appears to be:

[test] 192.168.1.120 ^ here

File “/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py”, line 280, in parse\_source

plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)

File “/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/yaml.py”, line 105, in parse

raise AnsibleParserError(e)

[WARNING]: \* Failed to parse /etc/ansible/hosts with ini plugin:

/etc/ansible/hosts:69: Expected key=value host variable assignment, got:

ansible

File “/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py”, line 280, in parse\_source

plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)

File “/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/ini.py”, line 138, in parse

raise AnsibleParserError(e)

[WARNING]: Unable to parse /etc/ansible/hosts as an inventory source

[WARNING]: No inventory was parsed, only implicit localhost is available

[WARNING]: provided hosts list is empty, only localhost is available. Note that

the implicit localhost does not match ‘all’

BR

Sandy

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 12, 2020, 12:01pm UTC](https://forum.ansible.com/t/no-hosts-matched/32443/6 "2020-03-12T12:01:29Z")

</div>

hi

it's pretty obvious from the error, with exact file and line number etc:

> [WARNING]: \* Failed to parse /etc/ansible/hosts with yaml plugin: Syntax Error
> 
> while loading YAML. did not find expected \<document start\> The error appears
> 
> to be in '/etc/ansible/hosts': line 48, column 1, but may be elsewhere in the
> 
> file depending on the exact syntax problem. The offending line appears to be:
> 
> [test] 192.168.1.120 ^ here
> 
> &nbsp;&nbsp;File "/usr/lib/python2.7/dist-packages/ansible/inventory/manager.py", line 280, in parse\_source
> 
> &nbsp;&nbsp;&nbsp;&nbsp;plugin.parse(self.\_inventory, self.\_loader, source, cache=cache)
> 
> &nbsp;&nbsp;File "/usr/lib/python2.7/dist-packages/ansible/plugins/inventory/yaml.py", line 105, in parse
> 
> &nbsp;&nbsp;&nbsp;&nbsp;raise AnsibleParserError(e)

But there is another problem as well:
