【发布时间】:2016-09-07 09:07:16
【问题描述】:
鉴于以下情况:
[root@vmutil01 ~]# cat /etc/issue
CentOS release 6.7 (Final)
[root@vmutil01 ~]# yum -y install centos-release-SCL
[ ... ]
[root@vmutil01 ~]# yum -y install python27
[ ... ]
[root@vmutil01 ~]# scl enable python27 bash
[root@vmutil01 ~]# python -V
Python 2.7.5
为什么我会得到这个结果?
[root@vmutil01 ansible]# ansible centos7_hosts -m ping
/usr/lib64/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
vmcentos7dev | SUCCESS => {
"changed": false,
"ping": "pong"
}
Ansible 版本甚至有警告,所以它绝对是与远程主机无关的本地事物:
[root@vmutil01 ansible]# ansible --version
/usr/lib64/python2.6/site-packages/cryptography/__init__.py:26: DeprecationWarning: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of cryptography will drop support for Python 2.6
DeprecationWarning
ansible 2.0.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
Ansible 似乎正在调用cryptography 的基本 Python 版本。这是这个版本的 Ansible 中的错误还是与 SCL 的工作方式有关?我需要做什么来修复它?
编辑以添加更多故障排除
问题与 Ansible 调用 Python 本身的方式有关,因为 /usr/bin/ansible 中的 she-bang 是 #!/usr/bin/python。如果我将其更改为 #!/usr/bin/env python 我会得到一个不同但仍然显示停止的错误:
[root@vmutil01 ansible]# ansible --version
Traceback (most recent call last):
File "/usr/bin/ansible", line 39, in <module>
from ansible.errors import AnsibleError, AnsibleOptionsError, AnsibleParserError
ImportError: No module named ansible.errors
看来问题出在 Ansible 上。
仍在寻找修复或解决方法...
【问题讨论】:
-
在运行 Ansible 之前启用 scl Python 后是否要打开一个新的 shell?如果你尝试
scl enable python27 "ansible --version"会发生什么 -
另外,有什么特殊原因导致您无法在操作系统不受限制的机器上运行 Ansible?
-
使用
scl enable python27 "ansible --version"直接执行会得到相同的结果,如果找不到合理的解决方案,我想我将不得不切换到 Ubuntu。
标签: python python-2.7 ansible centos6