# fact not being set when using raw module

**URL:** <https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677>\
**Category:** Ansible Project\
**Created:** [May 31, 2018, 8:22pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677 "2018-05-31T20:22:39Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt\_Hickok](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Matt\_Hickok](https://forum.ansible.com/u/Matt_Hickok)\
**Post date:** [May 31, 2018, 8:22pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/1 "2018-05-31T20:22:39Z")

</div>

Hello, I’m trying to to run a raw command against a linux host which does not have python installed. Here is my playbook:

- hosts: all  
gather\_facts: false  
tasks:
- name: Get OS Release Information  
raw: uname -a  
register: os\_information
- debug:  
var: os\_information
- set\_fact:  
os\_information: “{{ os\_information.stdout }}”

It looks like it works but the fact cache for this host is still empty.

ok: [2caf4ecbb1f4] =\> {“ansible\_facts”: {“os\_information”: {“changed”: true, “failed”: false, “rc”: 0, “stderr”: “Shared connection to 2caf4ecbb1f4 closed.\r\n”, “stdout”: “Linux 2caf4ecbb1f4 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017 x86\_64 x86\_64 x86\_64 GNU/Linux\r\n”, “stdout\_lines”: [“Linux 2caf4ecbb1f4 4.9.60-linuxkit-aufs #1 SMP Mon Nov 6 16:00:12 UTC 2017 x86\_64 x86\_64 x86\_64 GNU/Linux”]}}, “changed”: false}

Any ideas?

Thanks!

---

<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:** [May 31, 2018, 9:51pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/2 "2018-05-31T21:51:19Z")

</div>

fact cache is populated by gathered facts, by default set\_fact does not.

---

<div class="post-metadata">

**Author:** ![Matt\_Hickok](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Matt\_Hickok](https://forum.ansible.com/u/Matt_Hickok)\
**Post date:** [June 1, 2018, 12:51pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/3 "2018-06-01T12:51:57Z")

</div>

Hey Brian, could you elaborate on that? What does set\_fact do if it does not populate the fact cache?

Also, I should note that I am using AWX so I am checking the option that says “use fact cache”

---

<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:** [June 1, 2018, 1:38pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/4 "2018-06-01T13:38:21Z")

</div>

It sets a var at the host scope, not really a gathered fact, though  
the name is misleading.

---

<div class="post-metadata">

**Author:** ![Matt\_Hickok](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Matt\_Hickok](https://forum.ansible.com/u/Matt_Hickok)\
**Post date:** [June 1, 2018, 2:02pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/5 "2018-06-01T14:02:05Z")

</div>

So is it possible to populate a manual fact to the persistent cache with a playbook?

---

<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:** [June 1, 2018, 2:05pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/6 "2018-06-01T14:05:52Z")

</div>

In latest versions, with the addition of the 'cacheable' option.

---

<div class="post-metadata">

**Author:** ![Matt\_Hickok](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Matt\_Hickok](https://forum.ansible.com/u/Matt_Hickok)\
**Post date:** [June 1, 2018, 2:12pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/7 "2018-06-01T14:12:16Z")

</div>

First of all, I guess I should try actually reading things (from set\_fact):“These variables will be available to subsequent plays during an ansible-playbook run, but will not be saved across executions even if you use a fact cache.”

And I am running the latest version of AWX that is available as far as I know, but maybe this isn’t new enough? Is there any documentation available o the ‘cacheable’ option? I’ll actually read it this time.

---

<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:** [June 1, 2018, 2:32pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/8 "2018-06-01T14:32:26Z")

</div>

`ansible-doc set_fact` will give you the documentation of the  
installed version you have available. This is not directly an awx  
version issue but an ansible one.

In any case here are the docs for the latest stable version:  
[http://docs.ansible.com/ansible/latest/modules/set\_fact\_module.html](http://docs.ansible.com/ansible/latest/modules/set_fact_module.html)

the option was added in Ansible 2.4

---

<div class="post-metadata">

**Author:** ![Matt\_Hickok](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Matt\_Hickok](https://forum.ansible.com/u/Matt_Hickok)\
**Post date:** [June 1, 2018, 3:21pm UTC](https://forum.ansible.com/t/fact-not-being-set-when-using-raw-module/27677/9 "2018-06-01T15:21:50Z")

</div>

That’s super helpful. Thank you much!
