realtebo
(realtebo)
July 31, 2018, 8:30pm
1
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.
If only localhost is available, why cannot run /bin/date against localhost?
Where is the host pattern?
Thanks in advance.
sivel
(sivel)
July 31, 2018, 8:32pm
2
realtebo
(realtebo)
July 31, 2018, 8:34pm
3
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.
realtebo
(realtebo)
July 31, 2018, 8:37pm
4
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
realtebo
(realtebo)
July 31, 2018, 8:39pm
5
I added a row with localhost
at the end of the config file without any success
realtebo
(realtebo)
July 31, 2018, 8:40pm
6
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?
realtebo
(realtebo)
July 31, 2018, 8:43pm
7
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