Giter Club home page Giter Club logo

Comments (7)

ansibot avatar ansibot commented on September 23, 2024 1

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.

bcoca avatar bcoca commented on September 23, 2024 1

i'll create an alias for yum/dnf to rpm to solve the pkg_mgr issue.

from ansible.

flowerysong avatar flowerysong commented on September 23, 2024

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.

christian-heusel avatar christian-heusel commented on September 23, 2024

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.

flowerysong avatar flowerysong commented on September 23, 2024

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.

christian-heusel avatar christian-heusel commented on September 23, 2024

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.

flowerysong avatar flowerysong commented on September 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.