我的计算机位于未连接到 Internet 的内部网络上,并且已将相关的 rpm 包复制到我的本地 dnf 存储库中。我正在尝试让 ansible 的 DNF 模块在另一台计算机上安装程序,但它弹出一条错误消息,指出未安装 python2-dnf。但是当我尝试安装该程序时,它已经安装了。任何人都知道出了什么问题?
我在下面放置了错误代码。
背景:
Ansible Control machine: Fedora 24 4.5.5-300.fc24.x86_64 GNU/LINUX
Ansible Client machine: Fedora 24 4.5.5-300.fc24.x86_64 GNU/LINUX
yum/dnf local repository: Centos 7 3.10.0-327.28.3.el7.x86_64 GNU/LINUX
[root@localhost ansible]# ansible all -m dnf -a "name=vim state=present"
192.168.10.10 | FAILED! => {
"changed": false,
"failed": true
, "msg": "python2-dnf is not installed, but it is required for the Ansible dnf module."
}
[root@localhost ansible]# yum install python2-dnf
Yum command has been deprecated, redirecting to '/usr/bin/dnf install python2-dnf'.
See 'man dnf' and 'man yum2dnf' for more information.
To transfer transaction metadata from yum to DNF, run:
'dnf install python-dnf-plugins-extras-migrate && dnf-2 migrate'
Last metadata expiration check: 0:12:08 ago on Tue Oct 18 04:57:11 2016.
Package python2-dnf-1.1.9-2.fc24.noarch is already installed, skipping.
Dependencies resolved.
Nothing to do.
Complete!
最佳答案
正如@GUIDO 所指出的,您需要在目标主机上使用 python2-dnf
。
Ansible module documentation 说:
在执行模块的主机上意味着在 Ansible
上下文中是播放的目标主机,而不是控制主机。
关于ansible - [Ansible][Fedora 24] DNF 模块需要 python2-dnf 但它已经安装,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/40107000/