# Starting from zero: warning about localhost at first command

**URL:** <https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218>\
**Category:** Ansible Project\
**Created:** [July 31, 2018, 8:30pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218 "2018-07-31T20:30:35Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:30pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/1 "2018-07-31T20:30:35Z")

</div>

I’m in ansible world for the first time.

I’m following the video: [https://www.ansible.com/resources/get-started](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.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [July 31, 2018, 8:32pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/2 "2018-07-31T20:32:43Z")

</div>

You might want to continue by starting at [https://docs.ansible.com/ansible/latest/user\_guide/intro\_getting\_started.html](https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html)

---

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:34pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/3 "2018-07-31T20:34:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:37pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/4 "2018-07-31T20:37:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:39pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/5 "2018-07-31T20:39:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:40pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/6 "2018-07-31T20:40:09Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![realtebo](https://avatars.discourse-cdn.com/v4/letter/r/6bbea6/32.png) [@realtebo](https://forum.ansible.com/u/realtebo)\
**Post date:** [July 31, 2018, 8:43pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/7 "2018-07-31T20:43:37Z")

</div>

Fixed!

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

---

<div class="post-metadata">

**Author:** ![Adam\_Morris](https://avatars.discourse-cdn.com/v4/letter/a/ecae2f/32.png) [@Adam\_Morris](https://forum.ansible.com/u/Adam_Morris)\
**Post date:** [August 1, 2018, 4:51pm UTC](https://forum.ansible.com/t/starting-from-zero-warning-about-localhost-at-first-command/28218/8 "2018-08-01T16:51:20Z")

</div>

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
