Starting from zero: warning about localhost at first command

I’m in ansible world for the first time.

I’m following the video: https://www.ansible.com/resources/get-started

Installation is succesfullu

At 8’:35’’ , i tried to run

`
ansible web -a /bin/date

`

but at this point I got

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

[WARNING]: Could not match supplied host pattern, ignoring: web

`

It’s very frustrating that the first command fails…

Sure, I must configure something, but I obviously do not what and where.

But before of that, I need to understand the erro.

    • Where is the host list?
    • What’s its goal
    • If only localhost is available, why cannot run /bin/date against localhost?
    • Where is the host pattern?
    • What’s its goal

Thanks in advance.

You might want to continue by starting at https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html

First step: Googling I find the command

`
ansible-config view

`

First line tells:

#inventory = /etc/ansible/hosts

So …

`
~$ cat /etc/ansible/hosts

This is the default ansible ‘hosts’ file.

Ah, thanks… Good old black-on-white rows to read. Thanks… I hate videos.

As you can see in my next post, in this same thread, I found config file. But no success, anyway

I added a row with localhost at the end of the config file without any success

Now the error is

`
$ ansible web -a /bin/date

[WARNING]: Could not match supplied host pattern, ignoring: web

[WARNING]: No hosts matched, nothing to do
`

What?

Fixed!

realtebo@DESKTOP-3QBL88J:~$ ansible localhost -a /bin/date localhost | SUCCESS | rc=0 >> Tue Jul 31 22:42:58 DST 2018

Ok, this is trying to match a host or group in the inventory file called "web" but you don't have one.

If you have an empty inventory file then it adds an implied "localhost" to the inventory, but warns you that this will not match the special "all" target. I.e. you can't run against an empty inventory file and just assume the machine you are running on will be configured.

The solution is to either create a web group in the inventory file with localhost in it, or change the target to localhost.

I hope that this helps