# set\_fact and fact caching

**URL:** <https://forum.ansible.com/t/set-fact-and-fact-caching/17386>\
**Category:** Ansible Project\
**Created:** [January 27, 2015, 11:58pm UTC](https://forum.ansible.com/t/set-fact-and-fact-caching/17386 "2015-01-27T23:58:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [January 27, 2015, 11:58pm UTC](https://forum.ansible.com/t/set-fact-and-fact-caching/17386/1 "2015-01-27T23:58:02Z")

</div>

Hi,

I'm implementing Ansible on a legacy infrastructure and would like to  
use it first to assess the damage (i.e. run in check mode).

There is some information that I've to gather by running commands,  
because it doesn't exist as facts, and later I use set\_fact to define  
facts that will be used by other tasks in calculating things.

Since the command module doesn't run in check mode, I was wondering if  
I could first run a playbook to gather the facts (both automatically by  
Ansible and through my command/set\_fact tasks) and use fact caching to  
later use these facts in another playbook run.

I tried it and it works fine for Ansible facts (with Redis), but not  
for the facts I created with set\_fact. Just wanted to check if that's  
expected, if there is a better way to do this and, finally, if anyone  
is interested in having this functionality (if it doesn't exist)?

There reason I'm doing all of this is to first show management how much  
entropy the legacy environment has, what would be changed if we start  
to conform to our standards, risks, etc.

Thanks,  
Giovanni

---

<div class="post-metadata">

**Author:** ![Giovanni\_Tirloni](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@Giovanni\_Tirloni](https://forum.ansible.com/u/Giovanni_Tirloni)\
**Post date:** [January 28, 2015, 11:52am UTC](https://forum.ansible.com/t/set-fact-and-fact-caching/17386/2 "2015-01-28T11:52:53Z")

</div>

It looks like a better way is to create a module in library/ that  
outputs custom facts in JSON format. Then fact caching works fine.

Giovanni
