New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ansible.builtin.package_facts
returns an empty list when manager=auto
#83143
Comments
Files identified in the description: If these files are incorrect, please update the |
This does not seem likely to be a bug. With the default options ( You can modify the order in which package managers are checked by passing a list to One way to apply this is to take advantage of the - ansible.builtin.package_facts:
manager: "{{ ansible_facts.pkg_mgr }}" |
This does not seem to be the case, as the other package managers are not available on the system (checked against the list on https://docs.ansible.com/ansible/latest/collections/ansible/builtin/package_facts_module.html#parameter-manager):
How could I find out which package manager the module has selected on its own? This logic correctly detects that apt is the package manager on the system:
But in this case this resulted in failure in a module that I do not control, so I'm not sure this is a "fix" here. |
The method of detection for each package manager varies, and is not necessarily checking for a binary in the path. The easiest way to test the hypothesis is to use
There are multiple possible fixes, as noted in my first response (plus others like modifying the template so it doesn't fail in this situation.) The simplest and probably most correct is to modify https://github.com/prometheus-community/ansible/blob/afc93495654330f5a25ab6a8f2604d8199c97345/roles/node_exporter/tasks/preflight.yml#L19-L21 to use |
Well yes and no, the Why dont you apply the logic you proposed in #83143 (comment) as default for |
Oh, I forgot that Whether the logic should be changed is a question for the core team, but even if they're open to it changing the default behaviour would be a backwards-incompatible change so probably won't be in a release until November at the earliest. So you'd still need to address it some other way in the meantime. |
i'll create an alias for yum/dnf to rpm to solve the |
* package_facts add alias support fixes #83143 Co-authored-by: Abhijeet Kasurde <[email protected]>
Summary
For one of our ansible hosts when invoking the
ansible.builtin.package_facts
module with no arguments (implies auto) gives an empty list, which breaks the downstream prometheus collection.While explicitly specifying
apt
works:This was first reported to prometheus-community/ansible#342 but turned out not to be a direct issue with the prometheus collection but rather the
package_facts
module.Issue Type
Bug Report
Component Name
package_facts
Ansible Version
Configuration
OS / Environment
Control host: Arch Linux (rolling)
Target host: Debian 12 (bookworm)
Steps to Reproduce
Exact reproduction steps are unclear as the problem occurs only on one of the 6 debian 12 hosts.
Expected Results
The gathered facts of the
package_facts
module are equal on a debian hosts for the two following commands.Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: