# ERROR: provided hosts list is empty

**URL:** <https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731>\
**Category:** Ansible Project\
**Created:** [March 12, 2015, 5:30pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731 "2015-03-12T17:30:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Guru\_Devanla](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@Guru\_Devanla](https://forum.ansible.com/u/Guru_Devanla)\
**Post date:** [March 12, 2015, 5:30pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731/1 "2015-03-12T17:30:00Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 12, 2015, 5:59pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731/2 "2015-03-12T17:59:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Guru\_Devanla](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@Guru\_Devanla](https://forum.ansible.com/u/Guru_Devanla)\
**Post date:** [March 12, 2015, 6:27pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731/3 "2015-03-12T18:27:43Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 12, 2015, 6:29pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731/4 "2015-03-12T18:29:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Guru\_Devanla](https://avatars.discourse-cdn.com/v4/letter/g/ee59a6/32.png) [@Guru\_Devanla](https://forum.ansible.com/u/Guru_Devanla)\
**Post date:** [March 12, 2015, 6:39pm UTC](https://forum.ansible.com/t/error-provided-hosts-list-is-empty/17731/5 "2015-03-12T18:39:50Z")

</div>

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
