# fact plugin example?

**URL:** <https://forum.ansible.com/t/fact-plugin-example/12020>\
**Category:** Ansible Project\
**Created:** [October 24, 2012, 5:52am UTC](https://forum.ansible.com/t/fact-plugin-example/12020 "2012-10-24T05:52:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Seth\_Vidal](https://avatars.discourse-cdn.com/v4/letter/s/7ba0ec/32.png) [@Seth\_Vidal](https://forum.ansible.com/u/Seth_Vidal)\
**Post date:** [October 24, 2012, 5:52am UTC](https://forum.ansible.com/t/fact-plugin-example/12020/1 "2012-10-24T05:52:47Z")

</div>

Hi,  
&nbsp;&nbsp;Does anyone have an example of how to add a fact plugin? I can't seem to find one and before I sift the code to see how to do it - I figured it was worth asking for an example.

-sv

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [October 24, 2012, 10:29am UTC](https://forum.ansible.com/t/fact-plugin-example/12020/2 "2012-10-24T10:29:39Z")

</div>

If you mean a fact module, see ansible-provisioning.

I don't know what a fact plugin is.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [October 24, 2012, 11:24am UTC](https://forum.ansible.com/t/fact-plugin-example/12020/3 "2012-10-24T11:24:08Z")

</div>

The setup module itself is probably the best example.

Just return an ansible\_facts hash wrapping the key-value pairs you  
would like to make available as variables.

Minimal example:

module.exit\_json(dict(ansible\_facts = dict(  
&nbsp;&nbsp;&nbsp;&nbsp;a = 1,  
&nbsp;&nbsp;&nbsp;&nbsp;b = [2 , 3, 4],  
&nbsp;&nbsp;&nbsp;&nbsp;c = dict(asdf=jkl, mnop=qrs)  
)))
