ERROR: provided hosts list is empty

3,961 views
Skip to first unread message

Guru Devanla

unread,
Mar 12, 2015, 1:59:07 PM3/12/15
to ansible...@googlegroups.com
Hello All,

I have a simple .yml file that looks like this.

- hosts: '{{ hosts }}'
  tasks:
    - include: tasks/apt_setup.yml app_user='{{ as_user }}'
    - include: tasks/python_setup.yml app_user='{{ as_user }}'

And I am invoking this script using the following command:
ansible-playbook -vvv --ask-sudo-pas local_play.yml --extra-vars 'hosts=localhost app_user=joe'

I get the following error:

ERROR: provided hosts list is empty

What am I doing wrong..

Thanks

Brian Coca

unread,
Mar 12, 2015, 1:59:50 PM3/12/15
to ansible...@googlegroups.com
try using a variable named 'target', hosts is a keyword and can lead
to confusion, in general do not use variables that overlap with
keywords.


--
Brian Coca

Guru Devanla

unread,
Mar 12, 2015, 2:27:43 PM3/12/15
to ansible...@googlegroups.com
Thanks Brian.

I tried target but go the same error.  I also tried to get rid of variable entirely with the following statement

- hosts: 'localhost'
  tasks:
    - name: test ping
      ping:

and I still see the same error. Looks like there is some other config file that is causing some issue.  Note, that this is specific to a machine and I am not getting this error on another machine. So,  am I missing some setting in /etc/ansible/hosts file?

Brian Coca

unread,
Mar 12, 2015, 2:29:59 PM3/12/15
to ansible...@googlegroups.com
newer ansible versions should 'just work' with localhost, any other
host you want to use should appear in inventory (default is
/etc/ansible/hosts) but you can even define in command line '-i
"hostname,"' < comma is important as it tells ansible it is a list.
> --
> 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 post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/81d8ac0e-e206-4b7d-ab66-ad8a95a33970%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca

Guru Devanla

unread,
Mar 12, 2015, 2:39:50 PM3/12/15
to ansible...@googlegroups.com
That is very strange.  The original etc/ansible/hosts file has all lines commented out.

I just added an entry like this

[dummy_hosts]
dummy

And everything starts working perfectly with the original file.

Thanks
Guru
Reply all
Reply to author
Forward
0 new messages