# fact caching no longer works after upgrading to Ansible 2.11

**URL:** <https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545>\
**Category:** Ansible Project\
**Created:** [July 25, 2021, 8:17pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545 "2021-07-25T20:17:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [July 25, 2021, 8:17pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/1 "2021-07-25T20:17:04Z")

</div>

Hi,

I had enabled fact caching using below commands when i was earlier using ansible 2.9 with python 2.7 (not sure about minor version though i know major version was python 2.xx) in WSL linux.

ASA facts module didn’t work with ansible 2.9. So i had to upgrade to ansible 2.11.2 with pythin 3.7.3 to make the module to work. After that, facts caching works only partially. Before upgrade, i could see the output of ios\_facts (ios\_facts module is equivalent to ‘gather facts: true’) and custom variables in the file created for the device. After ansible upgrade, the file contains only the outout of ios\_facts and not that of custom variables.

I am using jsonfile fact cahing plugin and the output of each device gets saved in a file in below mentioned location and the file would have the name that we specify as inventory\_hostname.

Is there any bug that makes fact caching incompatible with ansible 2.11 or would the upgrade from ansible 2.9 with python 2 to ansible 2.11 with pyton 3.7 have introduced any bug - would uninstalling WSL linux and ansible and re-installing them from scratch help?

[defaults]  
transport = paramiko  
host\_key\_checking = False  
timeout = 5  
inventory = /etc/ansible/hosts  
gathering = smart  
fact\_caching = jsonfile  
fact\_caching\_connection = /tmp/facts\_cache  
fact\_caching\_timeout = 7200

[persistent\_connection]  
command\_timeout = 150

Thanks,  
Vikram

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 26, 2021, 3:15pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/2 "2021-07-26T15:15:16Z")

</div>

There should not be an incompatible change,I tested with other facts  
plugins (no IOS devices here) and I don't see the issue, can you  
provide more details?

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [July 27, 2021, 6:32pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/3 "2021-07-27T18:32:09Z")

</div>

Hi Brian,

Below is my playbook. As you can see, i am gathering device facts (using ios\_facts) and also saving the output of a output in a custom variable. I have the given the contents of file saved by fact cache plugin below the script, as you can see only the ios\_facts output is saved.  
I changed fact cache pluigin from jsonfile to yaml, still the same issue. So iam wondering now if facts cache plugin was meant to only store output of device facts (like ios\_facts) and not store contents of a custom variable?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 27, 2021, 6:59pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/4 "2021-07-27T18:59:15Z")

</div>

> From your example I have no way to tell what you think has changed. At

least provide the difference in the data sets. I would check the fact  
gathering itself first though, not the cached data.

---

<div class="post-metadata">

**Author:** ![Vikram\_S](https://avatars.discourse-cdn.com/v4/letter/v/90db22/32.png) [@Vikram\_S](https://forum.ansible.com/u/Vikram_S)\
**Post date:** [July 27, 2021, 7:29pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/5 "2021-07-27T19:29:17Z")

</div>

Hi Brian,

In the script mentioned earlier, the output of a command which is stored as custom variable ‘show\_bootinfo’ would be stored in the file (pasting that part of the script below) and i have viwed the output in the file. But i no longer see output of custom variables stored in the file created by fact cache plugin. I see only the output of device facts (ios\_facts) being stored.

When i run the script with -vvvv option, below is what is displayed for the TASK which creates custom variable. Unfortunately, i don’t have the option to provide the difference in the data sets as i uninstalled ansible and did a fresh installation hoping that may fix this issue. So whatever info i had seen earlier is lost.  
Now i wonder if facts cache plugin was meant to only store output of device facts (like ios\_facts) or would it store contents of a custom variable?

- name: GATHER BOOT INFO  
asa\_command:  
commands: “sh run boot system”

register: show\_bootinfo

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [July 27, 2021, 8:04pm UTC](https://forum.ansible.com/t/fact-caching-no-longer-works-after-upgrading-to-ansible-2-11/35545/6 "2021-07-27T20:04:12Z")

</div>

Hii

> When i run the script with -vvvv option, below is what is displayed for the TASK which creates custom variable. Unfortunately, i don't have the option to provide the difference in the data sets as i uninstalled ansible and did a fresh installation hoping that may fix this issue. So whatever info i had seen earlier is lost.

So, the installation procedure you've chosen is getting in the way.

> From terms like "Uninstalling", "fresh installation" etc I take it

that you are using some OS package manager to install ansible/python.  
In order to diagnose potential differences between ansible versions,  
you should have two environments that ONLY differ in their ansible  
version.  
I found that python virtualenvs are a great way to do this. They allow  
you to have multiple ansible versions next to each other, potentially  
multiplied by whatever python version(s) you might have (for example  
through pyenv).  
So, my suggestion is to set up two virtualenvs with the ansible  
versions you suspect differ, and then run the exact same  
playbook/inventory/etc, and then compare output.  
See [https://docs.ansible.com/ansible/latest/installation\_guide/intro\_installation.html#installing-and-upgrading-ansible-with-pip](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-and-upgrading-ansible-with-pip)

Dick
