# Jinja macros as plugins

**URL:** <https://forum.ansible.com/t/jinja-macros-as-plugins/1710>\
**Category:** Project Discussions\
**Tags:** macro, plugin, collections, jinja2\
**Created:** [October 13, 2023, 8:49pm UTC](https://forum.ansible.com/t/jinja-macros-as-plugins/1710 "2023-10-13T20:49:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [October 13, 2023, 8:49pm UTC](https://forum.ansible.com/t/jinja-macros-as-plugins/1710/1 "2023-10-13T20:49:27Z")

</div>

Continuing the discussion from [Playbook-wide Jinja2 macros](http://forum.ansible.com/t/playbook-wide-jinja2-macros/922/8) over in #Get Help :

TL;DR — The idea is to allow macros defined in a collection’s `plugins/macros` directory to be available in Jinja expressions without requiring additional syntax in much the same way that custom lookups and filters are made available now.

@nitzmahone from the core team provided interesting technical background with implications for implementation, particularly that it would be much cleaner if such a feature were restricted to collections. I (@utoddl) provided a use case, and @gwmngilfen suggested this discussion could be a better fit here in #Project Discussions than in #Get Help, so _here it is!_

Since macros are built-in to Jinja, it should be possible to implement all-Jinja solutions to problems that would otherwise require implementing custom filters in Python, and _that_ may be one step farther than some Ansible users are ready to take.

I’d be particularly interested in hearing use cases and thoughts from others.
