# ansible\_facts\['ansible\_os\_family'\] vs. ansible\_facts\['os\_family'\]

**URL:** <https://forum.ansible.com/t/ansible-facts-ansible-os-family-vs-ansible-facts-os-family/30890>\
**Category:** Ansible Project\
**Created:** [July 28, 2019, 4:18pm UTC](https://forum.ansible.com/t/ansible-facts-ansible-os-family-vs-ansible-facts-os-family/30890 "2019-07-28T16:18:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![user89](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@user89](https://forum.ansible.com/u/user89)\
**Post date:** [July 28, 2019, 4:18pm UTC](https://forum.ansible.com/t/ansible-facts-ansible-os-family-vs-ansible-facts-os-family/30890/1 "2019-07-28T16:18:37Z")

</div>

Hello community!

To determine how to reference variable which store OS family type i ran:ansible node1 -m setup

Which throw a lot of output but there was:

192.168.24.24 | SUCCESS =\> {

“ansible\_facts”: {  
…,  
“ansible\_os\_family”: “RedHat”,  
…  
},  
“changed”: false  
}

Based on it i reference in task to family vars as follows:

when: ansible\_facts[‘ansible\_os\_family’] == ‘RedHat’

But ansible throw me an error:  
The conditional check ‘ansible\_facts[‘ansible\_os\_family’] == "RedHat"’ failed. The error was: error while evaluating conditional (ansible\_facts[‘ansible\_os\_family’] == "RedHat"): **‘dict object’ has no attribute ‘ansible\_os\_family’**

And only when i changed my task to:

when: ansible\_facts[‘os\_family’] == ‘RedHat’ # without “ansible\_” for key dict

It start to work. Why is it so, I am saw in output key “ **ansible\_os\_family** ”, not “ **os\_family** ”? Should I delete all leading “ansible\_” from output setup module? Is it documented?

P.S. also it works even with just:  
when: ansible\_os\_family == ‘RedHat’ condition.

---

<div class="post-metadata">

**Author:** ![cassell](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cassell](https://forum.ansible.com/u/cassell)\
**Post date:** [July 28, 2019, 8:16pm UTC](https://forum.ansible.com/t/ansible-facts-ansible-os-family-vs-ansible-facts-os-family/30890/2 "2019-07-28T20:16:40Z")

</div>

> Hello community!
> 
> To determine how to reference variable which store OS family type i ran:  
> ansible node1 -m setup
> 
> Which throw a lot of output but there was:  
> 192.168.24.24 | SUCCESS =\> {  
> "ansible\_facts": {  
> ...,  
> "ansible\_os\_family": "RedHat",  
> ...  
> },  
> "changed": false  
> }
> 
> Based on it i reference in task to family vars as follows:  
> when: ansible\_facts['ansible\_os\_family'] == 'RedHat'
> 
> But ansible throw me an error:  
> The conditional check 'ansible\_facts['ansible\_os\_family'] ==  
> \"RedHat\"' failed. The error was: error while evaluating conditional  
> (ansible\_facts['ansible\_os\_family'] == \"RedHat\"): \*'dict object' has  
> no attribute 'ansible\_os\_family'\*  
> \*  
> \*  
> And only when i changed my task to:  
> when: ansible\_facts['os\_family'] == 'RedHat' # without "ansible\_" for  
> key dict
> 
> It start to work. Why is it so, I am saw in output key  
> "\*ansible\_os\_family\*", not "\*os\_family\*"? Should I delete all leading  
> "ansible\_" from output setup module? Is it documented?

There is an effort to move gathered facts into their own namespace under ansible\_facts, dropping the ansible\_ prefix on each fact.

> P.S. also it works even with just:  
> when: ansible\_os\_family == 'RedHat' condition.

This is the "old" way of accessing the fact, though I'd expect it to remain supported for a long time.

V/r,  
James Cassell

---

<div class="post-metadata">

**Author:** ![user89](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@user89](https://forum.ansible.com/u/user89)\
**Post date:** [July 28, 2019, 8:32pm UTC](https://forum.ansible.com/t/ansible-facts-ansible-os-family-vs-ansible-facts-os-family/30890/3 "2019-07-28T20:32:41Z")

</div>

Thanks for answer James!

Also want to know dropping leading “ansible\_” are not documented and i am asking not on vain or i just read without attention?

вс, 28 июл. 2019 г., 22:16 James Cassell \<[fedoraproject@cyberpear.com](mailto:fedoraproject@cyberpear.com)\>:
