# Gathering Facts about Hosts Not Included in the Play

**URL:** <https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658>\
**Category:** Ansible Project\
**Created:** [October 10, 2013, 3:57pm UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658 "2013-10-10T15:57:58Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Phillip\_Verheyden](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@Phillip\_Verheyden](https://forum.ansible.com/u/Phillip_Verheyden)\
**Post date:** [October 10, 2013, 3:57pm UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658/1 "2013-10-10T15:57:58Z")

</div>

I’m attempting to setup an nfsserver and nfsclients in a playbook. These are my host names:

appserver-1  
appserver-2  
appserver-3

I want the NFS server to exist on appserver-1 and then mount the folder on appserver-2 and 3. Here are my plays:

hosts: appserver-1  
vars:

- nfs\_device: eth2  
roles:
- nfsserver

hosts: appserver\*:!appserver-1  
roles:

- nfsclient

Within the nfsserver role, I export this fact:

- name: Export the nfsserver IP fact  
set\_fact:  
nfsserver\_host: “{{ ansible\_{{ nfs\_device }}[‘ipv4’][‘address’] }}”

And then I’m attempting to use that in the nfsclient role:

- name: configure /etc/fstab on clients  
mount: name=“{{ nfsclient\_mountpoint }}” src=“{{ nfsserver\_host }}:{{ nfsserver\_mountpoint }}” fstype=nfs opts=“{{ nfsoptions }}” state=mounted

When I run with -v, I get a the following on the nfs server:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 11, 2013, 12:13am UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658/2 "2013-10-11T00:13:22Z")

</div>

All you need do here is start a baby-play before that talks to the hosts:

- hosts: all  
tasks: 

- hosts: somehosts  
tasks:

- …

And that will gather them.

Fact caching in Ansible from prior runs is something we’re interested in doing for a future release.

---

<div class="post-metadata">

**Author:** ![Guillaume\_Subiron](https://avatars.discourse-cdn.com/v4/letter/g/c77e96/32.png) [@Guillaume\_Subiron](https://forum.ansible.com/u/Guillaume_Subiron)\
**Post date:** [October 16, 2013, 4:11pm UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658/3 "2013-10-16T16:11:20Z")

</div>

This solution works fine (task: is not even usefull), but  
unfortunately prevents use of the --limit argument because facts may  
not be gathered again, and some tasks will failed.

The inability to use retry files is quite frustrating.

So despite this trick, I really hope fact caching is coming soon 🙂

Le 13/10/10 20:13, Michael DeHaan claviotta :

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [October 16, 2013, 7:54pm UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658/4 "2013-10-16T19:54:04Z")

</div>

- hosts: localhost  
gather\_facts: False  
tasks:
- setup:  
delegate\_to: “{{item}}”  
#with\_items: [‘host1’, ‘host2’]  
with\_items: groups[‘qa’]

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [October 16, 2013, 7:57pm UTC](https://forum.ansible.com/t/gathering-facts-about-hosts-not-included-in-the-play/13658/5 "2013-10-16T19:57:43Z")

</div>

“task: is not even usefull”. It’s “tasks”, and it’s useful to lots of people 🙂

I’m not sure what you mean about not being able to use retry files either.

I do understand what you are saying about --limit and fact gathering, which is why we want to cache facts in a future release.
