# Deprecation of ANSIBLE\_JINJA2\_EXTENSIONS - what to 'do'?

**URL:** <https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256>\
**Category:** Get Help\
**Tags:** deprecation, jinja2\
**Created:** [February 4, 2026, 11:26am UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256 "2026-02-04T11:26:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuliaMono](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JuliaMono](https://forum.ansible.com/u/JuliaMono)\
**Post date:** [February 4, 2026, 11:26am UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256/1 "2026-02-04T11:26:33Z")

</div>

I am running a sizable deployment of ansible with a bit of tooling around it to make things work for me.

Some templates for example for network and network services gather extensive amount of data from the environment, process it and generate configuration using jinja2 and templates. I use the jinja2 ‘do’ extension via ANSIBLE\_JINJA2\_EXTENSIONS to overcome jinja2s scoping specifics and carry data out of loops etc.

ansible-core seems to have deprecated adding jinja2 extensions without addressing how to migrate current usecases to different solutions.

any ideas how to deal with jinja loop contexts and carrying data out of them without using the ‘do’ extension?

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 4, 2026, 11:34am UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256/2 "2026-02-04T11:34:07Z")

</div>

I never used it, but from [its description](https://jinja.palletsprojects.com/en/stable/extensions/#expression-statement) it sounds very similar to `{% set _ = <expression> %}` ([Template Designer Documentation — Jinja Documentation (3.1.x)](https://jinja.palletsprojects.com/en/stable/templates/#assignments)). Maybe that can be used instead (without any extension)?

---

<div class="post-metadata">

**Author:** ![JuliaMono](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JuliaMono](https://forum.ansible.com/u/JuliaMono)\
**Post date:** [February 4, 2026, 11:50am UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256/3 "2026-02-04T11:50:23Z")

</div>

Thanks for referring me back to the documentation about the scoping behavior :).

`set` alone doesn’t seem to solve it (it doesn’t carry the data out of the loop) but i will try to use the namespace feature that is documented there and available since jinja 2.10. I didn’t even know about that. \<3

Thanks, Felix

---

<div class="post-metadata">

**Author:** ![JuliaMono](https://avatars.discourse-cdn.com/v4/letter/j/f04885/32.png) [@JuliaMono](https://forum.ansible.com/u/JuliaMono)\
**Post date:** [February 4, 2026, 1:21pm UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256/4 "2026-02-04T13:21:53Z")

</div>

I totally misuderstood what you meant, sorry. Sure, assigning the result (usually `None` of the append call to `_` should do the trick as well … sorry for the confusion and thanks again.

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [February 7, 2026, 11:18am UTC](https://forum.ansible.com/t/deprecation-of-ansible-jinja2-extensions-what-to-do/45256/5 "2026-02-07T11:18:37Z")

</div>

No worries, I’m glad you figured it out 🙂
