Skip to content
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

pkg_mgr: prohibit pkg5 usage on Altlinux #76457

Merged
merged 1 commit into from Dec 9, 2021
Merged

pkg_mgr: prohibit pkg5 usage on Altlinux #76457

merged 1 commit into from Dec 9, 2021

Conversation

ptrnine
Copy link
Contributor

@ptrnine ptrnine commented Dec 3, 2021

SUMMARY

The current implementation expects /usr/bin/pkg as pkg5 package manager, but this is not suitable for Altlinux. There is an perl-Package rpm package that has an executable with the same path as pkg5 (/usr/bin/pkg).
Since the pkg5 takes precedence over apt, this patch is required to select an appropriate package manager on Altlinux.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

pkg_mgr

Filter out the /usr/bin/pkg because on Altlinux it is actually the
perl-Package (not Solaris package manager).
Since the pkg5 takes precedence over apt, this workaround is
required to select the suitable package manager on Altlinux.
@ansibot ansibot added affects_2.13 bug This issue/PR relates to a bug. core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Dec 3, 2021
@mkrizek
Copy link
Contributor

mkrizek commented Dec 7, 2021

@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Dec 7, 2021
@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Dec 7, 2021
def pkg_mgrs(self, collected_facts):
# Filter out the /usr/bin/pkg because on Altlinux it is actually the
# perl-Package (not Solaris package manager).
# Since the pkg5 takes precedence over apt, this workaround
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect, apt-get has higher precedence than pkg

Copy link
Contributor Author

@ptrnine ptrnine Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's correct:

# A list of dicts. If there is a platform with more than one
# package manager, put the preferred one last. If there is an
# ansible module, use that as the value for the 'name' key.

Each next pkg['name'] in PKG_MGRS can rewrite the pkg_mgr_name:

for pkg in PKG_MGRS:
if os.path.exists(pkg['path']):
pkg_mgr_name = pkg['name']

And so pkg5 takes precedence over apt.

Copy link
Member

@bcoca bcoca Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, I didn't look at all the code and assumed assumed there was a break on match, its last, not first, found wins ... which makes me want to rewrite this section.

Not only can we have multiple package managers (add fact with list), but the traversal can be reversed + break to make it perform better. Another 'optimization' would be to create diff lists for OS families.

@bcoca bcoca merged commit 894fbd6 into ansible:devel Dec 9, 2021
@bcoca
Copy link
Member

bcoca commented Dec 9, 2021

merged this to fix this specific problem, but making note on needing to rethink pkg manager detection.

bcoca pushed a commit to bcoca/ansible that referenced this pull request Dec 15, 2021
Filter out the /usr/bin/pkg because on Altlinux it is actually the
perl-Package (not Solaris package manager).
Since the pkg5 takes precedence over apt, this workaround is
required to select the suitable package manager on Altlinux.
@ansible ansible locked and limited conversation to collaborators Dec 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.13 bug This issue/PR relates to a bug. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. new_contributor This PR is the first contribution by a new community member. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants