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

selinux 0.3.0 in a virtualenv with non default python3 yields broken ansible #72

Open
mafalb opened this issue Jan 14, 2024 · 0 comments

Comments

@mafalb
Copy link

mafalb commented Jan 14, 2024

On a RHEL 9 system I want to install ansible and molecule in a virtualenv

$ python3 --version
Python 3.9.18

But I don't want to use the default python3 (or platform-python) but python 3.11, which is packaged for RHEL 9

$ python3.11 --version
Python 3.11.5
$ python3.11 -m venv venv
$ . venv/bin/activate
(venv) $ pip install ansible molecule-podman
Collecting ansible
...

Here is the problem:

(venv) $ ansible --version
Traceback (most recent call last):
  File "/home/mafalb/Documents/venv/bin/ansible", line 5, in <module>
    from ansible.cli.adhoc import main
  File "/home/mafalb/Documents/venv/lib64/python3.11/site-packages/ansible/cli/__init__.py", line 102, in <module>
    from ansible.module_utils.common.file import is_executable
  File "/home/mafalb/Documents/venv/lib64/python3.11/site-packages/ansible/module_utils/common/file.py", line 12, in <module>
    import selinux  # pylint: disable=unused-import
    ^^^^^^^^^^^^^^
  File "/home/mafalb/Documents/venv/lib64/python3.11/site-packages/selinux/__init__.py", line 106, in <module>
    check_system_sitepackages()
  File "/home/mafalb/Documents/venv/lib64/python3.11/site-packages/selinux/__init__.py", line 102, in check_system_sitepackages
    raise Exception(
Exception: Failed to detect selinux python bindings at ['/usr/local/lib64/python3.11/site-packages', '/usr/local/lib/python3.11/site-packages', '/usr/lib64/python3.11/site-packages', '/usr/lib/python3.11/site-packages']

selinux 0.3.0 was pulled in as a dependency of molecule-podman
I wonder if something is wrong with selinux 0.3.0, so I try to install older version

(venv) $ pip install ansible molecule-podman 'selinux<0.3.0'
...

and voila, ansible seems to work

(venv) $ ansible --version
ansible [core 2.16.2]
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/mafalb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/mafalb/Documents/venv/lib64/python3.11/site-packages/ansible
  ansible collection location = /home/mafalb/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/mafalb/Documents/venv/bin/ansible
  python version = 3.11.5 (main, Sep  7 2023, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/home/mafalb/Documents/venv/bin/python3.11)
  jinja version = 3.1.3
  libyaml = True

Is this a misbehaviour of selinux 0.3.0?

mafalb added a commit to mafalb/ansible-collection-ansible that referenced this issue Jan 15, 2024
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

No branches or pull requests

1 participant