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?
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
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.