I'm trying to run this Ansible task to gather package_facts, but the task is failing on SLES 15 machines, but is working fine on SLES 12 machines.
- name: Gathering facts
ansible.builtin.package_facts:
manager: auto
I'm getting a warning on SLES 15 machines:
[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
And the error I'm getting is:
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."}
Tried installing rpm in the Remote Node. But it's still failing.
And when I tried to import rpm module in python interactive shell, this is the error I'm getting:
"Failed to import system RPM module."
ImportError: Failed to import system RPM module. Make sure RPM Python bindings are installed on your system.
In your case the error message
means that the import of the already via
pip install rpminstalled Python RPM package failed and as you commentedbecause of missing
python-rpmbindings.It is documented within the
package_factsmodule – Package information as facts under Requirementsand to resolve you'll probably need to do an additional
pip install python3-rpm.