msg: Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!

I was trying to use copy module which rely on libselinux-python when selinux is enabled i think.

The weird thing is I have checked every single environment, they have already have latest libselinux-python installed…

What can I do now?

Much appreciated.

some info:

sudo yum install -y libselinux-python
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile

$ ansible --version
ansible 1.7

Are you checking on the nodes you're trying to manage, or on the machine
that has ansible installed?

My guess is you need it on the nodes, so a task above the copy like

- name: install selinux bindings
  yum: name=libselinux-python state=present

will push it out before you need to use it.

I was checking on the node. and yes, i have tried run playbook like this… But it’s still complaining same error while using copy module.

The copy module uses the exact same functions for this as other modules.

Could this be a machine where the bindings are yet not installed?

Same issue occured, and your solution solved me. thanks!

I had this issue Ansible 2.6.2 on Fedora 28 system using Ansible local connection. Doing /usr/bin/dnf install -y libselinux-python fixed it for me. Thanks.

I wonder why Ansible doesn’t install needed prereq?

My understanding its because not all systems have selinux enabled so having it as a dependency its not a good idea. Although if you run into this issue the output tells you what it needs.