# Accessing cached facts from custom module

**URL:** <https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036>\
**Category:** Ansible Developer\
**Tags:** awx\
**Created:** [October 15, 2020, 7:17am UTC](https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036 "2020-10-15T07:17:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zeek3000](https://avatars.discourse-cdn.com/v4/letter/z/eada6e/32.png) [@Zeek3000](https://forum.ansible.com/u/Zeek3000)\
**Post date:** [October 15, 2020, 7:17am UTC](https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036/1 "2020-10-15T07:17:40Z")

</div>

Hello,

I’m trying to access facts that are cached in AWX from within my custom network module, preferably without having to make an API call. I need to check if an element already exists in the fact cache so that it doesn’t get overwritten by running the module

Is it possible to access these cached facts by using ansible\_facts, and how can I make that available to my custom module?

Thanks!

---

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [October 15, 2020, 7:52am UTC](https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036/2 "2020-10-15T07:52:41Z")

</div>

You can do this by conditionally executing your custom module on whether the custom variable (fact) that comes from your module is defined.

---

<div class="post-metadata">

**Author:** ![Zeek3000](https://avatars.discourse-cdn.com/v4/letter/z/eada6e/32.png) [@Zeek3000](https://forum.ansible.com/u/Zeek3000)\
**Post date:** [October 20, 2020, 7:39am UTC](https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036/3 "2020-10-20T07:39:31Z")

</div>

Can’t do that sadly as the custom module needs to run regardless; it’s just a small part of a function that I need to reference the fact cache before that particular fact gets set.

---

<div class="post-metadata">

**Author:** ![iamroddo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/iamroddo/32/321_2.png) [@iamroddo](https://forum.ansible.com/u/iamroddo)\
**Post date:** [October 20, 2020, 10:48am UTC](https://forum.ansible.com/t/accessing-cached-facts-from-custom-module/34036/4 "2020-10-20T10:48:00Z")

</div>

The facts in the cache are accessible as any other fact, you just don’t need to set them. It’s possible that I’m not really understanding the issue.
