You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ansible package_facts在SLES 15执行失败:无法导入rpm模块

问题:Ansible package_facts模块在SLES 15执行失败,SLES 12运行正常

任务代码

- name: Gathering facts
  ansible.builtin.package_facts: 
    manager: auto

报错信息

警告内容

[WARNING]: Found "rpm" but Failed to import the required Python library (rpm)
on SLES15's Python /usr/bin/python3.6. Please read module documentation
and install in the appropriate location. If the required library is installed,
but Ansible is using the wrong Python interpreter, please consult the
documentation on ansible_python_interpreter

错误信息

FAILED! => {"changed": false, "msg": "Could not detect a supported package manager from the following list: ['pkg', 'portage', 'apt', 'rpm'], or the required Python library is not installed. Check warnings for details."}

已尝试操作及后续报错

  • 已在远程SLES 15节点安装rpm包,但问题未解决
  • 在Python交互shell中导入rpm模块时,出现如下错误:
"Failed to import system RPM module."
ImportError: Failed to import system RPM module. Make sure RPM Python bindings are installed on your system.

解决方法

SLES 15中,Python3对应的RPM绑定库并非默认的rpm包,而是单独的python3-rpm包,执行以下步骤修复:

  1. 在SLES 15远程节点运行安装命令:
zypper install python3-rpm
  1. 安装完成后,重新执行Ansible的package_facts任务即可正常运行。

内容的提问来源于stack exchange,提问作者Ash

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 18:04:59