How can I know what version of Jinja2 my ansible is using?

馋奶兔 提交于 2021-01-21 08:44:05

问题


I tried to use pip list and pip freeze without success.
It might be something obvious but I am not able to find it so far.


回答1:


Drop this file as ./action_plugins/jin_ver.py:

from ansible.plugins.action import ActionBase
import jinja2


class ActionModule(ActionBase):

    def run(self, tmp=None, task_vars=None):
        result = super(ActionModule, self).run(tmp, task_vars)
        return dict(msg=jinja2.__version__)

And execute this playbook ./test_jin.yaml:

---
- hosts: localhost
  gather_facts: no
  tasks:
    - action: jin_ver

You should see something like this:

$ ansible-playbook test_jin.yaml -v
TASK [jin_ver] *****************************************
ok: [localhost] => {"changed": false, "msg": "2.8"}



回答2:


The answer to this could vary somewhat depending on your platform but generally:

$ pip show jinja2
Metadata-Version: 1.0
Name: Jinja2
Version: 2.2.1
Summary: A small but fast and easy to use stand-alone template engine written in pure python.
...

If you're on a platform where python and related dependencies are installed via a package manager then you could also check that way. For example on RHEL:

$ rpm -q python-jinja2
python-jinja2-2.2.1-3.el6.x86_64


来源:https://stackoverflow.com/questions/49040013/how-can-i-know-what-version-of-jinja2-my-ansible-is-using

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!