# Get a list of --limit servers

**URL:** <https://forum.ansible.com/t/get-a-list-of-limit-servers/23079>\
**Category:** Ansible Project\
**Created:** [November 22, 2016, 10:19pm UTC](https://forum.ansible.com/t/get-a-list-of-limit-servers/23079 "2016-11-22T22:19:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bmccarthy](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bmccarthy](https://forum.ansible.com/u/bmccarthy)\
**Post date:** [November 22, 2016, 10:19pm UTC](https://forum.ansible.com/t/get-a-list-of-limit-servers/23079/1 "2016-11-22T22:19:06Z")

</div>

I’m using the icinga2-ansible-add-hosts role, which creates config files for each host.  
My playbook starts like this:

---

<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:** [November 22, 2016, 11:42pm UTC](https://forum.ansible.com/t/get-a-list-of-limit-servers/23079/2 "2016-11-22T23:42:32Z")

</div>

​try the ‘play\_hosts’ variable.​

---

<div class="post-metadata">

**Author:** ![bmccarthy](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bmccarthy](https://forum.ansible.com/u/bmccarthy)\
**Post date:** [November 23, 2016, 12:05am UTC](https://forum.ansible.com/t/get-a-list-of-limit-servers/23079/3 "2016-11-23T00:05:59Z")

</div>

‘play\_hosts’ doesn’t work because the ‘icinga2-ansible-add-hosts’ role is only applied to “{{ hosts | default(‘monitoring\_servers’) }}”

What I’m trying to get is the list of hosts that

- hosts: all  
gather\_facts: yes  
runs against, which is not all of the hosts in my inventory.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [November 23, 2016, 6:52pm UTC](https://forum.ansible.com/t/get-a-list-of-limit-servers/23079/4 "2016-11-23T18:52:37Z")

</div>

If you just want to make sure you are going to hit the right hosts before you run the playbook, use the --list-hosts command line parameter option of ansible-playbook.

I use --list-hosts and --list-tasks a lot.

Hope this helps,

Jon
