Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aborting, target uses selinux but Python bindings (libselinux-Python) aren't installed

Tags:

python

ansible

I am trying to run Ansible playbook command and getting an error as below.

fatal: [localhost]: FAILED! => {"changed": false, "msg": "Aborting, target
uses selinux but python bindings (libselinux-python) aren't installed!"}

When I checked for libselinux-python, it showsit is already available.

[root@host all]# sudo yum list installed |grep libselinux-python
libselinux-python3.x86_64            2.5-15.el7              @rhel-7-server-rpms

Please provide your input if anyone has faced and resolved this.

Below are my Python and Ansible versions installed on server.

[root@ xxx bin]# python --version
Python 3.6.5

[root@xxx bin]# which python
/root/.pyenv/shims/python

[root@xxx bin]# ansible --version
ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /root/.pyenv/versions/3.6.5/lib/python3.6/site-packages/ansible
  executable location = /root/.pyenv/versions/3.6.5/bin/ansible
  python version = 3.6.5 (default, Jun 18 2020, 17:32:20) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]

[root@ xxx bin]#
like image 564
Nagendra Vummadi Avatar asked Jul 30 '20 13:07

Nagendra Vummadi


2 Answers

I've just lost a whole day to this and I managed to solve it running sudo yum install libselinux-python3

like image 144
kami95 Avatar answered Sep 21 '22 14:09

kami95


These answers may be a little old now, so I'll say that while using Rocky Linux 8.4 (RHEL clone) the package names in dnf have changed from the Ansible docs. Ansible says it should be policycoreutils-python but it's actually python3-policycoreutils and python3-libselinux.

So you can install it with:

dnf install python3-policycoreutils python3-libselinux
like image 37
Clinton D'Annolfo Avatar answered Sep 18 '22 14:09

Clinton D'Annolfo