fact module return values

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

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

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