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

Fix pip-managed ansible #4380

Merged
merged 1 commit into from
Aug 24, 2023
Merged

Conversation

holmanb
Copy link
Member

@holmanb holmanb commented Aug 23, 2023

Fix pip-managed ansible

PEP 668 disallows installing packages via pip outside of virtual
environments, to avoid breaking due to conflicting system packages.

Ansible is unlikely to be installed in the base system, and if it is and
the user still chooses to use `install_method: pip`, that would be an
invalid configuration.

This flag exists to allow users to bootstrap ansible to run as a
controller. The alternative solution would be to require virtual
environments, however this is often packaged as a separate dependency,
which further complicates bootstrap. Allow installing ansible outside of
virtual environments via pip's --break-system-packages.

Fixes GH-4244

fixes #4244

Test

tox -re integration-tests -- tests/integration_tests/modules/test_ansible.py

environments, to avoid breaking due to conflicting system packages.

Ansible is unlikely to be installed in the base system, and if it is and
the user still chooses to use `install_method: pip`, that would be an
invalid configuration.

This flag exists to allow users to bootstrap ansible to run as a
controller. The alternative solution would be to require virtual
environments, however this is often packaged as a separate dependency,
which further complicates bootstrap. Allow installing ansible outside of
virtual environments via pip's --break-system-packages.
@holmanb
Copy link
Member Author

holmanb commented Aug 23, 2023

@blackboxsw #4356 is a duplicate of your older report of the same issue (#4244).

I will just close the new one as dup and mark the old one priority and link them, since we don't need to keep both around.

@blackboxsw blackboxsw self-assigned this Aug 24, 2023
Copy link
Collaborator

@blackboxsw blackboxsw left a comment

Choose a reason for hiding this comment

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

@holmanb as you suggest, this approach is safe from an ansible pip-installed extensions perspective and the typical intent of an Ansible consumer wanting to have fine-grained control of the version of anisble and extensions installed via pip on the system. Even PEP 668 refernces Ansible as one of those use-cases where this override is desirable behavior:
In some cases, however, it’s useful and intentional to install a Python package from outside of the distro that influences the behavior of distro-shipped commands. This is common in the case of software like Sphinx or Ansible which have a mechanism for writing Python-language extensions. A user may want to use their distro’s version of the base software (for reasons of paid support or security updates) but install a small extension from PyPI, and they’d want that extension to be importable by the software in their base system.

@holmanb holmanb merged commit b417b21 into canonical:main Aug 24, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_ansible_controller fails to use pip to install packages on Lunar
2 participants