Ansible fails to run ansible.builtin.package_facts
This document (000021838) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 15 SP6 (SLES 15 SP6)
Situation
Ansible is available in the Systems Management module. Running the ansible.builtin.package_facts
task fails with an exception.
Example:
- Install Ansible
zypper install ansible-core
- Create a minimal playbook
cat ./playbook.yml
- name: Test package_facts
hosts: localhost
gather_facts: false
tasks:
- name: Run package_facts
ansible.builtin.package_facts: - Run Ansible
ansible-playbook -i localhost -c local playbook.yml
Exception:
TASK [Run package_facts] *****
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: future feature annotations is not defined
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n File \"<stdin>\", line 12, in <module>\n File \"<frozen importlib._bootstrap>\", line 971, in _find_and_load\n File \"<frozen importlib._bootstrap>\", line 951, in _find_and_load_unlocked\n File \"<frozen importlib._bootstrap>\", line 894, in _find_spec\n File \"<frozen importlib._bootstrap_external>\", line 1157, in find_spec\n File \"<frozen importlib._bootstrap_external>\", line 1131, in _get_spec\n File \"<frozen importlib._bootstrap_external>\", line 1112, in _legacy_get_spec\n File \"<frozen importlib._bootstrap>\", line 441, in spec_from_loader\n File \"<frozen importlib._bootstrap_external>\", line 544, in spec_from_file_location\n File \"/tmp/ansible_ansible.builtin.package_facts_payload_9h98d5e0/ansible_ansible.builtin.package_facts_payload.zip/ansible/module_utils/basic.py\", line 5\nSyntaxError: future feature annotations is not defined\n", "module_stdout": "", "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error", "rc": 1}
Resolution
The resolution is to manually install the missing package for Python RPM bindings:
zypper install python311-rpm
Cause
This exception is thrown because gathering package facts on RPM-based operating systems requires Python RPM bindings. The package ansible-core-2.18.3-150400.9.3.2
is missing a dependency for the package python311-rpm
, so it's not being installed automatically when Ansible is being installed.
Status
Additional Information
This has been reported to engineering, so future versions of ansible-core
should have that missing dependency included.
Disclaimer
This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.
- Document ID:000021838
- Creation Date: 15-May-2025
- Modified Date:15-May-2025
-
- SUSE Linux Enterprise Server
For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com