Not getting fact_caching to work

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


Any help is appreciated.

Thanks in advance.

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

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,jinja2.ext.i18n”,
“ANSIBLE_GATHERING”: “smart”,
“ANSIBLE_CACHE_PLUGIN”: “jsonfile”,
“ANSIBLE_CACHE_PLUGIN_CONNECTION”: “/home/awx”

}

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? :wink:

Thanks again.

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.

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. ;).