问题描述
仍然必须保留一些CentOS5主机,它们已配置好以使用CentOS库回购,例如 https://hastebin.com/ojopevanas.ini .在主机上使用yum时,效果很好.但是,当我尝试使用ansible时,例如:
Still have to keep some CentOS5 hosts, they have yum configured to use CentOS vault repo like this https://hastebin.com/ojopevanas.ini. That works fine when use yum there on host.When however I try to use ansible for that, like:
- name: "Install OS packages"
yum: pkg={{item}} state=installed
with_items:
- dos2unix
- vim
我得到"msg": "python2 bindings for rpm are needed for this module. python2 yum module is needed for this module"
注意:主机在default24旁边安装了python26在清单文件中,主机名旁边有ansible_python_interpreter =/usr/bin/python26(否则,ansible甚至无法-m ping).其他可处理的任务与此主机配合正常
NOTE: the host has python26 installed next to default24in the inventory file hostname has ansible_python_interpreter=/usr/bin/python26 next to it (otherwise ansible cannot even -m ping). Other ansible tasks works fine with this host
推荐答案
yum
模块需要rpm
Python模块,该模块由rpm-python
软件包提供.在您的系统上,这是为Python 2.4安装的;您尚未为Python 2.6安装它.这是一个二进制模块,必须从源代码进行编译(它是rpm发行版的一部分).
The yum
module requires the rpm
Python module, which is provided by the rpm-python
package. On your system, this is installed for Python 2.4; you haven't installed it for Python 2.6. This is a binary module that must be compiled from source (it is part of the rpm distribution).
如果您需要支持CentOS 5,最简单的解决方案可能是使用command
模块来代替yum
模块:
If you need to support CentOS 5, the easiest solution is probably to use the command
module in lieu of the yum
module:
- name: "Install OS packages"
command: "yum install -y -e0 -d2 {{item}}"
with_items:
- dos2unix
- vim
这篇关于CentOS 5. ansible_python_interpreter =/usr/bin/python26.仍然不能使用yum:模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!