# Are facts carried forward?

**URL:** <https://forum.ansible.com/t/are-facts-carried-forward/16073>\
**Category:** Ansible Project\
**Created:** [August 29, 2014, 3:22pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073 "2014-08-29T15:22:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Dur](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Michael\_Dur](https://forum.ansible.com/u/Michael_Dur)\
**Post date:** [August 29, 2014, 3:22pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073/1 "2014-08-29T15:22:49Z")

</div>

We have many playbooks, and groups.  
I notice when I do a full site run that at the beginning of the ‘top level’ playbooks, that is those referenced by site.yml, that facts are gathered each time.  
I realize I can disable gathering facts for a given playbook.  
Are facts that are previously gathered carried forward, allowing us to gather just once for a run?

Thanks!  
-Michael

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [August 29, 2014, 3:29pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073/2 "2014-08-29T15:29:21Z")

</div>

Answered this exact same question here yesterday:

Facts are available throughout the playbook run, or longer, if fact caching is enabled.

[http://docs.ansible.com/playbooks\_variables.html#fact-caching](http://docs.ansible.com/playbooks_variables.html#fact-caching)

---

<div class="post-metadata">

**Author:** ![kesten\_broughton1](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kesten\_broughton1](https://forum.ansible.com/u/kesten_broughton1)\
**Post date:** [August 29, 2014, 5:44pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073/3 "2014-08-29T17:44:28Z")

</div>

Fact-caching will eliminate the need for the following workaround, but if you are stuck in pre 1.8 ansible…

If you have a bunch of plays in a site.yml and are a big fan of --start-at-task like i am, then there is a problem if downstream plays also require gathered facts.Having gather\_facts: yes for every play slows things down.

- hosts: all  
gather\_facts: yes

- hosts: group1  
gather\_facts: no # faster not to gather\_facts if we got them above  
roles:

- role-that-uses-facts

But then if you start-at-task on the group1 play you don’t have the facts you need.

My solution was to have the first role always gather facts for normal runs.

- hosts: zoo  
gather\_facts: “{{ zoo\_facts | default(‘no’)}}”

Then when debugging/developing i run with  
ansible-playbook -i hosts site.yml --start-at-task=“task in zoo role” -e “zoo\_facts=yes”

So we can start mid run, and switch on gathering facts for that role, but normally only the first play will gather facts.

---

<div class="post-metadata">

**Author:** ![Henry\_Finucane](https://avatars.discourse-cdn.com/v4/letter/h/94ad74/32.png) [@Henry\_Finucane](https://forum.ansible.com/u/Henry_Finucane)\
**Post date:** [August 30, 2014, 7:11pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073/4 "2014-08-30T19:11:20Z")

</div>

Are you aware of 'smart' fact gathering? I think this might ameliorate  
your problems:

[http://docs.ansible.com/intro\_configuration.html#gathering](http://docs.ansible.com/intro_configuration.html#gathering)

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [September 2, 2014, 4:33pm UTC](https://forum.ansible.com/t/are-facts-carried-forward/16073/5 "2014-09-02T16:33:01Z")

</div>

Smart fact gathering won’t rerun fact gathering on a host that has already gathered, but it will not gather hosts explicitly on hosts that have not been gathered.

So it’s basically a performance tweak.
