Comments (7)
Files identified in the description:
If these files are incorrect, please update the component name
section of the description or use the component bot command.
from ansible.
i'll create an alias for yum/dnf to rpm to solve the pkg_mgr
issue.
from ansible.
This does not seem likely to be a bug.
With the default options (manager: ['auto']
and strategy: first
) package_facts
will iterate through the list of supported package managers and return information for the first one found. The most likely explanation for the observed behaviour is that on this particular system another package manager is installed and is found before apt
, so it returns a different set of packages than when called specifically asking for apt
.
You can modify the order in which package managers are checked by passing a list to manager:
, or you can request that information from all available managers be returned by using strategy: all
.
One way to apply this is to take advantage of the pkg_mgr
fact, which uses more sophisticated logic to attempt to locate the appropriate default system package manager:
- ansible.builtin.package_facts:
manager: "{{ ansible_facts.pkg_mgr }}"
from ansible.
The most likely explanation for the observed behaviour is that on this particular system another package manager is installed and is found before
apt
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):
$ rpm
zsh: command not found: rpm
$ portage
zsh: command not found: portage
$ pkg
zsh: command not found: pkg
$ pacman
zsh: command not found: pacman
$ apk
zsh: command not found: apk
$ pkg_info
zsh: command not found: pkg_info
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:
$ ansible -m setup xerophyte
[...]
"ansible_pkg_mgr": "apt",
[...]
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.
from ansible.
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 strategy: all
and see if you get a non-empty package list, but you could also run the module with each other supported package manager to see which one returns nothing.
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.
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 manager: "{{ ansible_facts.pkg_mgr }}"
.
from ansible.
Well yes and no, the rpm
package manager got detected because the package python3-rpm
happens to be installed on this system (it got pulled as dependency for sth) and uninstalling it fixes the issue. In my opinion this is a clear sign of a broken detection logic tho 🤔
Why dont you apply the logic you proposed in #83143 (comment) as default for manager=auto
to just fallback on the value of ansible_facts.pkg_mgr
?
from ansible.
Oh, I forgot that pkg_mgr
doesn't actually map cleanly to the options here, since rpm
is the backend for multiple frontends. It's still possible to use, but not as simple as my initial claim.
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.
from ansible.
Related Issues (20)
- unable to set terminal parameters HOT 1
- Append list element works different between core 2.11.12 and 2.14.14 HOT 5
- Allow unarchive command to skip listing archive content / Allow user to provide tool as a parameter HOT 5
- Add setting to fail on missing/empty role HOT 4
- Pass handlers into imported playbooks HOT 4
- Chinese Language Display Issue HOT 3
- Error in atomic_move when path is filename only HOT 2
- ERROR! 'listen' is not a valid attribute for a Block HOT 4
- Trying to create a postgresqlflexibleserver fail with an API internal server error HOT 3
- `user` module use of chmod/chown can change files outside of home dir HOT 1
- get_url error if tile character (~) is in url HOT 4
- Windows command works with winrm but hangs with SSH HOT 2
- Allow retry/loops on blocks HOT 1
- package/dnf5 doesn't seem to install packages on Fedora 41 HOT 3
- community.windows.win_scheduled_task fails to update when Windows is using regional settings with dots in time. HOT 1
- ansible.builtin.password_hash filter return a value when an undefined variable is provided HOT 5
- copy task changes file permissions of the existing destination file when becoming an unprivileged user although mode is not specified HOT 1
- Request all ansible-navigator command options to be documented on docs.ansible.com HOT 1
- (auto-added by VS-Code) new line on Ansible-Vault breaks HMAC verification. HOT 1
- tags are not inherited by role dependencies, breaking the dependencies HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ansible.