Trouble with python bindings error (libselinux-python not installed) on RHEL8

796 views
Skip to first unread message

Robbie

unread,
Jul 22, 2020, 6:11:41 PM7/22/20
to Ansible Project
Hello all.

I've been trying to troubleshoot a problem for days and I haven't been able to find anything online that refers to RHEL8/Centos8.I have success running on RHEL/Centos7, but I'm trying to push to the new platform. Ikeep getting this error:
TASK [genjson: Generate F5 JSON - Nodes] ****************************************************************************************************************************************************
task path
: /home/admsplitb/Lab-Infrastructure/roles/f5_dclb/tasks/main.yml:6
fatal
: [genjson-1]: FAILED! => {"changed": false, "checksum": "60caf69c5c72c2814e3b1688a9564a86205778ed", "msg": "Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!"}


My version of ansible and python
(py3venv) [user@lab playbooks]$ ansible --version
ansible
2.9.11
  config file
= /home/user/Lab-Infrastructure/playbooks/ansible.cfg
  ansible python
module location = /home/user/py3venv/lib64/python3.8/site-packages/ansible
  executable location
= /home/user/py3venv/bin/ansible
  python version
= 3.8.0 (default, Mar  9 2020, 18:02:46) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]


I tried to link previous packages as indicated in this github issue

First ensuring that the packages are installed:
yum install libselinux-python
And then linking the files to your environment.
cd ~/py3venv/lib64/python3.8/site-packages/
ln
-s /usr/lib64/python3.6/site-packages/selinux
ln
-s /usr/lib64/python3.6/site-packages/_selinux.cpython-36m-x86_64-linux-gnu.so


But in RHEL8, the package names have changed. 
yum install libselinux
yum install python3
-libselinux


Anybody experience this and solve it yet?

Robbie

unread,
Jul 27, 2020, 9:22:41 AM7/27/20
to Ansible Project
I made some slight progress, but haven't figured out how to get this to work entirely in my py3venv.

With some troubleshooting, I noticed the following: setup is reporting that selinux is present.
(py3venv) [user@lab playbooks]$ ansible -m setup -i rawhide.vgr, all | grep selinux
       
"ansible_selinux": {
       
"ansible_selinux_python_present": true,

(py3venv) [user@lab playbooks]$ which ansible
~/py3venv/bin/ansible

But when I try to ensure that my python interpreter is the one from my virtual py3venv environment, I recieve present: false. I tried this for
(py3venv) [user@lab playbooks]$ ansible -e 'ansible_python_interpreter=~/py3venv/bin/python3' -m setup -i rawhide.vgr, all | grep selinux
        "ansible_selinux": {
            "status": "Missing selinux Python library"
        "ansible_selinux_python_present": false,


I tried these following as parameters for the ansible_python_interpreter. Here are the responses.
False         /usr/bin/python
False         /usr/bin/python3
False         ~/py3venv/bin/python
False         ~/py3venv/bin/python3
True           /usr/libexec/platform-python

So, if i run my original command with the final ansible interpreter, it works.
ansible-playbook -e 'ansible_python_interpreter=/usr/libexec/platform-python' playbook.yml


How can I get my python3 virtual environment to work like I want it to?



Reply all
Reply to author
Forward
0 new messages