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]#
I've just lost a whole day to this and I managed to solve it running sudo yum install libselinux-python3
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With