【发布时间】:2020-05-30 10:07:21
【问题描述】:
我正在尝试使用以下任务在我的 python3 环境中安装需求文件
pip:
python3: yes
requirements: ./requirements/my_requirements.txt
extra_args: -i http://mypypi/windows/simple
我检查了控制器节点 (RH7) 上运行的是哪个版本的 ansible,它是 3.6.8
ansible-playbook 2.9.9
config file = None
configured module search path = ['/home/{hidden}/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible-playbook
python version = 3.6.8 (default, Jun 11 2019, 15:15:01) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
No config file found; using defaults
但是我收到以下错误:
fatal: [default]: FAILED! => {"changed": false, "msg": "The Python 2 bindings for rpm are needed for this module. If you require Python 3 support use the `dnf` Ansible module
instead.. The Python 2 yum module is needed for this module. If you require Python 3 support use the `dnf` Ansible module instead."}
我的控制器节点正在运行 RH7。 目标是 centos7(由 vagrantfiles 提供)
现在有人知道如何解决这个问题吗?
【问题讨论】:
-
这不是你的控制器给你一个问题,而是你的节点,我会说。在节点上安装 python 3 将是一个解决方案。
-
嗯,这就是我试图用 ansible 做的事情......这是我的 ansible 脚本中完成的第一件事,安装 python3。成功了。但是现在到了 pip 安装其他库的时候了..我得到了上述错误
-
您是否按照错误消息的建议尝试使用
dnf模块?如果有,结果如何? -
no..因为我不确定如果我要尝试安装在不同风格的操作系统上是否会失败。我所做的是使用 virtual_command 属性来显式调用 python3。 (不幸的是,我认为其中一些模块需要工作......似乎我也不得不依赖命令模块)