# set\_fact retain the fact between run?

**URL:** <https://forum.ansible.com/t/set-fact-retain-the-fact-between-run/16968>\
**Category:** Ansible Project\
**Created:** [December 5, 2014, 1:17am UTC](https://forum.ansible.com/t/set-fact-retain-the-fact-between-run/16968 "2014-12-05T01:17:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Steve\_Kieu](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@Steve\_Kieu](https://forum.ansible.com/u/Steve_Kieu)\
**Post date:** [December 5, 2014, 1:17am UTC](https://forum.ansible.com/t/set-fact-retain-the-fact-between-run/16968/1 "2014-12-05T01:17:08Z")

</div>

Hi Team,

I read that it is retained between each play.

So I got

TASK: [web\_base | set fact CUSTOMER\_LOCATOR\_PORT] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
ok: [demo-web-kr] =\> {“ansible\_facts”: {“CUSTOMER\_LOCATOR\_PORT”: “52360”}}

But then I run  
ansible -i hosts ‘demo-web-kr’ -u root -k -msetup|grep LOCATOR

found nothing about that variable. (I did remove the grep and search for it 🙂 .

And it looks like the same when using ansible-playbook. In the real example on my hosts file I set

CUSTOMER\_LOCATOR\_PORT=“{{ansible\_CUSTOMER\_LOCATOR\_PORT|default(60000|random(50000,10))}}”

and the set\_fact is in one of the role task but it does not work - that means it changes every time I run playbook.

Any idea why?

thanks in advance.

---

<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:** [December 5, 2014, 1:19am UTC](https://forum.ansible.com/t/set-fact-retain-the-fact-between-run/16968/2 "2014-12-05T01:19:35Z")

</div>

Indeed they can!

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