Score:-1

Ansible is failed for some of the servers while performing user add task

cn flag

Below is the error :

FAILED! => {"ansible_facts": {"discovered_interpreter_pyt hon": "/usr/bin/python"}, "changed": false, "checksum": "2ca063f74f5a03d16fb6db0 dba613f2ec60f97b2", "msg": "Aborting, target uses selinux but python bindings (l ibselinux-python) aren't installed!"}

sv flag
Welcome to ServerFault. Did you really read the error message?
Score:2
cz flag

You need to install the indicated package on the target host before trying to manipulate user accounts.

On old RHEL/CentOS 7 systems you should install libselinux-python. On modern systems such as RHEL 8 and Fedora it is named python3-libselinux.

Score:0
nc flag

if you are using a version of ansible that use python2.7 and also your OS is centos 8, follow the below structure:

pip2.7 install selinux

if you did not set your default python to version 2.7 (on target host):

cd /usr/bin/
# below command will create a symbolic link to python2.7
ln -s python2.7 python
Score:0
cn flag

As the error states, Ansible needs Python bindings for selinux on Linux systems.

For RHEL or Fedora,

yum install libselinux-python*

will install these for python3, and also python2 in the case of RHEL 7.

Michael Hampton avatar
cz flag
The old name `libselinux-python` does not work on RHEL 8 or Fedora.
John Mahowald avatar
cn flag
The wildcard matches libselinux-python3, which is still provided by python3-libselinux last I checked CentOS 8.
Michael Hampton avatar
cz flag
Not anymore in RHEL 8.4.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.