# Not getting fact\_caching to work

**URL:** <https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086>\
**Category:** AWX Project\
**Tags:** awx\
**Created:** [June 3, 2020, 9:21pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086 "2020-06-03T21:21:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [June 3, 2020, 9:21pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/1 "2020-06-03T21:21:42Z")

</div>

Hi all,

Long time ansible cli user but fairly new to AWX.

I am trying to figure out how to enable fact caching, and verify it is enabled. I currently have set:

In the playbook running in the template:  
gather\_facts: True

In AWX: Settings → Jobs → EXTRA ENVIRONMENT VARIABLES:  
“CACHE\_PLUGIN\_CONNECTION”: “/var/lib/awx/facts”,  
“ANSIBLE\_CACHE\_PLUGIN”: “jsonfile”

But every time a job runs it seems to take a long time to run the setup module (and seems in fact to be running it on every host). Are there any other settings I’m missing? And I’ve looked in $CACHE\_PLUGIN\_CONNECTION for a tmp directory or one named ‘cache’ or any .json files that I would assume would be created but am not finding anything.

AWX 9.2.0  
Ansible 2.9.3

```auto

```

Any help is appreciated.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [June 24, 2020, 11:07pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/2 "2020-06-24T23:07:25Z")

</div>

I also tried per the documentation putting a copy of ansible.cfg in the project root directory with:

fact\_caching = jsonfile  
fact\_caching\_connection = ./facts

This same configuration works from ansible but not from AWX.

Does anyone have insight on this?

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:** [June 25, 2020, 3:40am UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/3 "2020-06-25T03:40:27Z")

</div>

We’ve got this to work on our instances of AWX (Ansible 2.9.7 running in AWX 11.2.0) by setting environment variables (under jobs/settings) as below;  
{  
“HOME”: “/var/lib/awx”,  
“ANSIBLE\_PYTHON\_INTERPRETER”: “python”,  
“ANSIBLE\_JINJA2\_EXTENSIONS”: “[jinja2.ext.do](http://jinja2.ext.do),jinja2.ext.i18n”,  
“ANSIBLE\_GATHERING”: “smart”,  
“ANSIBLE\_CACHE\_PLUGIN”: “jsonfile”,  
“ANSIBLE\_CACHE\_PLUGIN\_CONNECTION”: “/home/awx”

}

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [June 25, 2020, 5:35pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/4 "2020-06-25T17:35:52Z")

</div>

Thanks much for the reply Rod but that didn’t quite work out as expected. Of the ~400 nodes only three recorded facts as being gathered onto the controller node (weird). And even then the only fact put into each file was:

{

“discovered\_interpreter\_python”: “/usr/bin/python”

}

We run the ‘big’ jobs overnight so I don’t watch them run, and the logs are quite a bit to go through but when we have run subsets of the ‘big’ jobs I have seen the system almost running out of memory (another reason I want to get fact\_cache working). I will spend some time looking at the awx\_task logs and the system logs and see if I can correlate some kind of system resource shortage. In the meantime, any other suggestions? 😉

Thanks again.

---

<div class="post-metadata">

**Author:** ![Christopher\_Meyers](https://avatars.discourse-cdn.com/v4/letter/c/3e96dc/32.png) [@Christopher\_Meyers](https://forum.ansible.com/u/Christopher_Meyers)\
**Post date:** [June 26, 2020, 12:50pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/5 "2020-06-26T12:50:23Z")

</div>

AWX fully implements the fact caching feature and doesn’t require that you set any ansible configs. If enabled for a job template and your playbook runs the setup module (gather\_facts: true). Then, after the job finishes, AWX will take the state of the per-host facts and persist them to the database. You can view the facts through the inventory host browser.

---

<div class="post-metadata">

**Author:** ![Michael\_M1](https://avatars.discourse-cdn.com/v4/letter/m/e274bd/32.png) [@Michael\_M1](https://forum.ansible.com/u/Michael_M1)\
**Post date:** [June 26, 2020, 1:19pm UTC](https://forum.ansible.com/t/not-getting-fact-caching-to-work/33086/6 "2020-06-26T13:19:01Z")

</div>

Thank you Christopher, that helps. I do see the facts now browsing within the inventory. I’ve got to get out of my old way of ansible-playbook cli thinking I suppose. ;).
