no hosts matched

621 views
Skip to first unread message

Sandy Hung

unread,
Mar 11, 2020, 6:15:11 AM3/11/20
to Ansible Project
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

Deepak Rohila

unread,
Mar 11, 2020, 6:21:32 AM3/11/20
to ansible...@googlegroups.com
hi, 
can you remove me from this group asap.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7912138a-9412-4cc5-9fb1-96d046112925%40googlegroups.com.

Mark Whaite

unread,
Mar 11, 2020, 6:40:59 AM3/11/20
to ansible...@googlegroups.com
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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/7912138a-9412-4cc5-9fb1-96d046112925%40googlegroups.com.


--
Mark Whaite, Systems Administrator
Adelard LLP
Adelard LLP, Units 24 Waterside, 44-48 Wharf Road, London N1 7UX
Tel: 020 7832 5850
Web: http://www.adelard.com

This e-mail, and any attachments, is confidential and for the use of the addressee only. If you are not the intended recipient, please telephone 020 7832 5850. We do not accept legal responsibility for this e-mail or any viruses.

Registered office: Stourside Place, Station Road, Ashford, Kent TN12 1PP
Registered in England & Wales no. OC 304551. VAT no. 454 489808

Vladimir Botka

unread,
Mar 11, 2020, 6:47:31 AM3/11/20
to Sandy Hung, ansible...@googlegroups.com
On Wed, 11 Mar 2020 03:15:11 -0700 (PDT)
Sandy Hung <sandy...@abagile.com> wrote:

> 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

For example

shell> cat myinventory
192.168.1.120 ansible_user=sandy ansible_sudo_pass='xxxxxxx'
ansible_connection=local

shell> ansible-inventory -i myinventory --list --vars
{
"_meta": {
"hostvars": {
"192.168.1.120": {
"ansible_connection": "local",
"ansible_sudo_pass": "xxxxxxx",
"ansible_user": "sandy"
}
}
},
"all": {
"children": [
"ungrouped"
]
},
"ungrouped": {
"hosts": [
"192.168.1.120"
]
}
}

HTH,

-vlado

sandy...@abagile.com

unread,
Mar 12, 2020, 6:15:39 AM3/12/20
to ansible...@googlegroups.com

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

  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

Dick Visser

unread,
Mar 12, 2020, 8:02:04 AM3/12/20
to ansible...@googlegroups.com
hi

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

On Thu, 12 Mar 2020 at 11:15, <sandy...@abagile.com> wrote:
> [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
>
> 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)


But there is another problem as well:

> [WARNING]: * Failed to parse /etc/ansible/hosts with ini plugin:
>
> /etc/ansible/hosts:69: Expected key=value host variable assignment, got:
>
> ansible


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT
Reply all
Reply to author
Forward
0 new messages