# Access facts in custom filter plugin

**URL:** <https://forum.ansible.com/t/access-facts-in-custom-filter-plugin/20419>\
**Category:** Ansible Project\
**Created:** [February 2, 2016, 12:41pm UTC](https://forum.ansible.com/t/access-facts-in-custom-filter-plugin/20419 "2016-02-02T12:41:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukasz\_Gorski1](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Lukasz\_Gorski1](https://forum.ansible.com/u/Lukasz_Gorski1)\
**Post date:** [February 2, 2016, 12:41pm UTC](https://forum.ansible.com/t/access-facts-in-custom-filter-plugin/20419/1 "2016-02-02T12:41:02Z")

</div>

Hi there,

First post here, if something is amiss on my part, please bear with me.

How do I access facts in my own filter plugin? I know I can (and did) write a function and pass the fact as an argument, but perhaps it is possible to get the fact’s value in the body of a filter function?

My specific use case is something like ‘fqdn\_rand’ in Puppet, but I guess if I had the facts accessible in plugins, I would just write more plugins to hide some more complicated or ugly things 🙂

Thanks in advance.

Best regards,  
Łukasz Górski

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [February 2, 2016, 2:41pm UTC](https://forum.ansible.com/t/access-facts-in-custom-filter-plugin/20419/2 "2016-02-02T14:41:00Z")

</div>

filter plugins don't have access to anything except the arguments  
passed directly:

arg1 | filter(arg2, arg3, ...)

---

<div class="post-metadata">

**Author:** ![Lukasz\_Gorski1](https://avatars.discourse-cdn.com/v4/letter/l/c6cbf5/32.png) [@Lukasz\_Gorski1](https://forum.ansible.com/u/Lukasz_Gorski1)\
**Post date:** [February 3, 2016, 10:23am UTC](https://forum.ansible.com/t/access-facts-in-custom-filter-plugin/20419/3 "2016-02-03T10:23:11Z")

</div>

I hoped for some clever hack… Thanks anyway 🙂

Best regards,  
Łukasz Górski

W dniu wtorek, 2 lutego 2016 15:41:06 UTC+1 użytkownik Brian Coca napisał:
