-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
portage: drop usage of gentoolkit, add knobs for --with-bdeps, --backtrack #5349
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
Not sure how to handle the failing tests. Running ansible with a different Python than the system python on Gentoo is nonsensical - /usr/bin/python shouldn't ever be a Python implementation that the Portage module isn't installed for. |
Docs Build 📝Thank you for contribution!✨ This PR has been merged and your docs changes will be incorporated when they are next published. |
Check out https://docs.ansible.com/ansible-core/devel/dev_guide/testing/sanity/import.html, it shows how to properly import Python modules that are not part of the standard library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Please add a changelog fragment.
Since it is possible that the module is run with another Python interpreter (could also simply be inside a venv), you need to use respawning to make sure that the module can fall back to the correct Python interpreter that has access to the required Python module. See https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/yum.py#L1693 and https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/dnf.py#L579 for how to do this (they both use https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/common/respawn.py, which is available since ansible-core 2.11, which since community.general 5.0.0 is the minimum supported version of ansible-core).
@@ -229,6 +239,8 @@ | |||
import os | |||
import re | |||
|
|||
from portage.dbapi import vartree | |||
from portage.exception import InvalidAtom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These imports need to be guarded, see https://docs.ansible.com/ansible/devel/dev_guide/testing/sanity/import.html for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I've addressed this and the respawn issue, and I've tested at runtime but I haven't tried terribly hard to break it.
Forgot to do the changelog before pushing just now, looking into that now.
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: John Helmert III <ajak@gentoo.org>
Signed-off-by: John Helmert III <ajak@gentoo.org>
To fix the |
SUMMARY
This solves the issue brought up in #3870. The Portage Ansible module depends on an external shell command, when it could simply use the Portage module on every system that uses Portage.
Additionally, this adds support for handling the
--with-bdeps
and--backtrack
emerge
command line options.ISSUE TYPE
COMPONENT NAME
Portage
ADDITIONAL INFORMATION
Similar to the other PR, this fixes the following kind of issue when running on a system that doesn't have the requisite external shell command: