How to update Jinja2 for Ansible

Hi,

regarding this issue: https://github.com/ansible/ansible/issues/57311

I’ve tried all the suggested ways of upgrading Jinja including the last one:

$ python -m pip install -U jinja2

Pip and the python pip upgrade both think I installed Jinja2 version 2.10.1 which has the required 'equalto' function. But when I execute the playbook it continues to fail and the version command still continues to return 2.7.2. which is th eversion it is not implemented yet.

$ python -c 'from jinja2 import __version__; print(__version__)'

So how/where can I configure the correct version to use for ansible?

Kind Regards
Sylvia

I’m no expert in these things but I suspect you may have upgraded the version of jinja2 in your user’s pip library, but when ansible runs it is picking up the version installed for all users - the ‘system’ version.

I’m not sure how exactly you resolve this. If you don’t have root/sudo access and can’t upgrade the system version of jinja2 then maybe you can install all of ansible in your users’ pip library, which I think will also pull in the newer version of jinja2.

Another alternative might be to set up a python venv, which you can then install whatever versions you need into, and run ansible from inside the venv.

It’s not something I do myself (I prefer to try and have one python and set of libraries for the whole virtual machine), so I can’t offer advice on setting up the venv.

Hopefully the above will at least give you some ideas for things to try.

Jon