滚动升级 TiDB 监控组件时报错

tidb版本从2.1.14升级至3.1.2
按照https://docs.pingcap.com/zh/tidb/v3.1/upgrade-tidb-using-ansible的操作方式,
在最后升级监控时报错

ansible-playbook rolling_update_monitor.yml

命令输出请见附件。
rolling_update_monitor.txt (63.9 KB)

查了一下,说是jinja2版本过低,
现在已经是2.10版本了,应该符合jinja2>=2.9.6的要求
Name: Jinja2
Version: 2.10

[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ sudo pip install --upgrade -r requirements.txt
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already up-to-date: ansible==2.7.11 in /usr/lib/python2.7/site-packages (from -r requirements.txt (line 1)) (2.7.11)
Collecting jinja2>=2.9.6 (from -r requirements.txt (line 2))
Downloading https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125kB)
|████████████████████████████████| 133kB 79kB/s
Collecting jmespath>=0.9.0 (from -r requirements.txt (line 3))
Downloading https://files.pythonhosted.org/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl
Requirement already satisfied, skipping upgrade: PyYAML in /usr/lib64/python2.7/site-packages (from ansible==2.7.11->-r requirements.txt (line 1)) (5.1)
Requirement already satisfied, skipping upgrade: paramiko in /usr/lib/python2.7/site-packages (from ansible==2.7.11->-r requirements.txt (line 1)) (2.4.1)
Requirement already satisfied, skipping upgrade: cryptography in /usr/lib64/python2.7/site-packages (from ansible==2.7.11->-r requirements.txt (line 1)) (2.2.2)
Requirement already satisfied, skipping upgrade: setuptools in /usr/lib/python2.7/site-packages (from ansible==2.7.11->-r requirements.txt (line 1)) (0.9.8)
Requirement already satisfied, skipping upgrade: MarkupSafe>=0.23 in /usr/lib64/python2.7/site-packages (from jinja2>=2.9.6->-r requirements.txt (line 2)) (1.0)
Requirement already satisfied, skipping upgrade: pynacl>=1.0.1 in /usr/lib64/python2.7/site-packages (from paramiko->ansible==2.7.11->-r requirements.txt (line 1)) (1.2.1)
Requirement already satisfied, skipping upgrade: pyasn1>=0.1.7 in /usr/lib/python2.7/site-packages (from paramiko->ansible==2.7.11->-r requirements.txt (line 1)) (0.4.2)
Requirement already satisfied, skipping upgrade: bcrypt>=3.1.3 in /usr/lib64/python2.7/site-packages (from paramiko->ansible==2.7.11->-r requirements.txt (line 1)) (3.1.4)
Requirement already satisfied, skipping upgrade: idna>=2.1 in /usr/lib/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (2.6)
Requirement already satisfied, skipping upgrade: cffi>=1.7; platform_python_implementation != “PyPy” in /usr/lib64/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (1.11.5)
Requirement already satisfied, skipping upgrade: enum34; python_version < “3” in /usr/lib/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (1.1.6)
Requirement already satisfied, skipping upgrade: six>=1.4.1 in /usr/lib/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (1.9.0)
Requirement already satisfied, skipping upgrade: asn1crypto>=0.21.0 in /usr/lib/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (0.24.0)
Requirement already satisfied, skipping upgrade: ipaddress; python_version < “3” in /usr/lib/python2.7/site-packages (from cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (1.0.22)
Requirement already satisfied, skipping upgrade: pycparser in /usr/lib/python2.7/site-packages (from cffi>=1.7; platform_python_implementation != “PyPy”->cryptography->ansible==2.7.11->-r requirements.txt (line 1)) (2.18)
Installing collected packages: jinja2, jmespath
Found existing installation: Jinja2 2.10
Uninstalling Jinja2-2.10:
Successfully uninstalled Jinja2-2.10
Found existing installation: jmespath 0.9.4
Uninstalling jmespath-0.9.4:
Successfully uninstalled jmespath-0.9.4
Successfully installed jinja2-2.7.2 jmespath-0.10.0
WARNING: You are using pip version 19.1.1, however version 20.2.2 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ pip show jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Name: Jinja2
Version: 2.11.2
Summary: A very fast and expressive template engine.
Home-page: https://palletsprojects.com/p/jinja/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD-3-Clause
Location: /usr/lib64/python2.7/site-packages
Requires: MarkupSafe
Required-by:

尝试升级了jinja2,报错依旧

TASK [set_fact] ********************************************************************************************************************************************************************************************
fatal: [10.0.0.59]: FAILED! => {“msg”: “The conditional check ‘((existing_api_keys[‘json’] | selectattr(“name”, “equalto”, “grafana_apikey”)) | list) | length == 1’ failed. The error was: no test named ‘equalto’\ \ The error appears to have been in ‘/data/tidb/tidb-ansible-v3.1.2/common_tasks/create_grafana_api_keys.yml’: line 24, column 3, but may\ be elsewhere in the file depending on the exact syntax problem.\ \ The offending line appears to be:\ \ \ - set_fact:\ ^ here\ ”}

[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ sudo pip uninstall jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling Jinja2-2.11.2:
Would remove:
/usr/lib64/python2.7/site-packages/Jinja2-2.11.2.dist-info/*
/usr/lib64/python2.7/site-packages/jinja2/*
Proceed (y/n)? y
Successfully uninstalled Jinja2-2.11.2
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ pip install jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Requirement already satisfied: jinja2 in /usr/lib/python2.7/site-packages (2.7.2)
Requirement already satisfied: markupsafe in /usr/lib64/python2.7/site-packages (from jinja2) (1.0)
WARNING: You are using pip version 19.1.1, however version 20.2.3 is available.
You should consider upgrading via the ‘pip install --upgrade pip’ command.
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ pip show jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Name: Jinja2
Version: 2.7.2
Summary: A small but fast and easy to use stand-alone template engine written in pure python.
Home-page: http://jinja.pocoo.org/
Author: Armin Ronacher
Author-email: armin.ronacher@active-4.com
License: BSD
Location: /usr/lib/python2.7/site-packages
Requires: markupsafe
Required-by:
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ sudo pip uninstall jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Uninstalling Jinja2-2.7.2:
Would remove:
/usr/lib/python2.7/site-packages/Jinja2-2.7.2-py2.7.egg-info
/usr/lib/python2.7/site-packages/jinja2
Proceed (y/n)? y
Successfully uninstalled Jinja2-2.7.2
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$
[tidb@10-0-0-15 tidb-ansible-v3.1.2]$ sudo pip install jinja2
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won’t be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting jinja2
Using cached https://files.pythonhosted.org/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib64/python2.7/site-packages (from jinja2) (1.0)
Installing collected packages: jinja2
Successfully installed jinja2-2.11.2

问题解决了,环境有问题
jinja2同时存在两个版本,2.11.2和2.7.2
把两个都卸载再重装就好了

:+1:

此话题已在最后回复的 1 分钟后被自动关闭。不再允许新回复。