# custom jinja filter inside role

**URL:** <https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279>\
**Category:** Ansible Project\
**Created:** [January 19, 2016, 4:49pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279 "2016-01-19T16:49:18Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Hleb\_Valoshka](https://avatars.discourse-cdn.com/v4/letter/h/2acd7d/32.png) [@Hleb\_Valoshka](https://forum.ansible.com/u/Hleb_Valoshka)\
**Post date:** [January 19, 2016, 4:49pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279/1 "2016-01-19T16:49:18Z")

</div>

I want to add own jinja filter to my role, is it possible? If yes, where I should put it. I’ve tried library subdir but unsuccessfully.

---

<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:** [January 19, 2016, 4:50pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279/2 "2016-01-19T16:50:33Z")

</div>

filter\_plugins/file\_with\_custom\_filter.py

---

<div class="post-metadata">

**Author:** ![Hleb\_Valoshka](https://avatars.discourse-cdn.com/v4/letter/h/2acd7d/32.png) [@Hleb\_Valoshka](https://forum.ansible.com/u/Hleb_Valoshka)\
**Post date:** [January 24, 2016, 2:12pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279/3 "2016-01-24T14:12:46Z")

</div>

It works if i put it to playbook base directory, but does not work if I put it inside a role.

---

<div class="post-metadata">

**Author:** ![Mirko\_Friedenhagen](https://avatars.discourse-cdn.com/v4/letter/m/838e76/32.png) [@Mirko\_Friedenhagen](https://forum.ansible.com/u/Mirko_Friedenhagen)\
**Post date:** [January 24, 2016, 11:06pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279/4 "2016-01-24T23:06:01Z")

</div>

Hello Hleb,

AFAIK putting this into the role dir requires Ansible 2.0.

Regards  
Mirko

---

<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:** [January 25, 2016, 8:01pm UTC](https://forum.ansible.com/t/custom-jinja-filter-inside-role/20279/5 "2016-01-25T20:01:29Z")

</div>

some of the plugin dirs broke in 1.9, but they shoudl all work in 2.0
