no hosts matched

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

hi,
can you remove me from this group asap.

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

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

cat myinventory

192.168.1.120 ansible_user=sandy ansible_sudo_pass='xxxxxxx'
ansible_connection=local

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

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

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

  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: