# fact module return values

**URL:** <https://forum.ansible.com/t/fact-module-return-values/21239>\
**Category:** Ansible Developer\
**Created:** [April 21, 2016, 11:20pm UTC](https://forum.ansible.com/t/fact-module-return-values/21239 "2016-04-21T23:20:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [April 21, 2016, 11:20pm UTC](https://forum.ansible.com/t/fact-module-return-values/21239/1 "2016-04-21T23:20:45Z")

</div>

Hey all,

Can anyone provide any guidance on how a fact module should return an optional fact that is empty?

Is it better to not list that fact at all in the response? So one could use “'fact in foo”

Or to list it, but just set its value to whatever the “emptiness” value is for the fact type (empty list, empty string, None, etc)?

Or something else?

Any existing modules that pick a specific behavior?

thanks,  
-tim

---

<div class="post-metadata">

**Author:** ![Matt\_Davis](https://avatars.discourse-cdn.com/v4/letter/m/ce7236/32.png) [@Matt\_Davis](https://forum.ansible.com/u/Matt_Davis)\
**Post date:** [April 21, 2016, 11:53pm UTC](https://forum.ansible.com/t/fact-module-return-values/21239/2 "2016-04-21T23:53:27Z")

</div>

Empty facts/vars are slightly harder to deal with than missing ones, IMHO. The precedent has been set numerous times in our own setup module, as (for instance), we don’t return the facter/ohai subtrees if facter/ohai aren’t present. With the recent addition of facts subsets, we can omit entire subtrees all over the place… I’d vote for “just don’t return it” (though for non-fact module returns, I usually prefer a consistent “shape” where it makes sense)…

-Matt

---

<div class="post-metadata">

**Author:** ![Tim1](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@Tim1](https://forum.ansible.com/u/Tim1)\
**Post date:** [April 22, 2016, 1:56am UTC](https://forum.ansible.com/t/fact-module-return-values/21239/3 "2016-04-22T01:56:12Z")

</div>

Thanks for the tips Matt! The setup module was a great example. I develop my playbooks with guards in place to handle when variables are not set by it, so I think I’ll go with your suggestion.

thanks!  
-tim
