问题
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