Ansible- libselinux-python Error

Hi Team,

i am getting bellow error:

i can see libselinux-python installed but i am getting below error not sure why

[root@s605141sl7vl402 ansible]# rpm -qa | grep libselinux-python
libselinux-python-2.5-15.el7.x86_64
[root@s605141sl7vl402 ansible]#

TASK [firmware : connect the VC] ************************************************************************************************************************************************************************************************************
task path: /data01/ansible/playbooks/roles/firmware/tasks/nic.yml:2
<127.0.0.1> ESTABLISH LOCAL CONNECTION FOR USER: root
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘( umask 77 && mkdir -p “echo /root/.ansible/tmp”&& mkdir /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448 && echo ansible-tmp-1596839965.56-8623-255860923309448=“echo /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448” ) && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘echo ~root && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/stat.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-8543Bm9eWG/tmpeIAjnY TO /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_stat.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/ /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_stat.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/opt/rh/python27/root/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_stat.py && sleep 0’
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-8543Bm9eWG/tmpvSF4kk/nic.ps1.j2 TO /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/source
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/ /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/source && sleep 0’
Using module file /usr/lib/python2.7/site-packages/ansible/modules/files/copy.py
<127.0.0.1> PUT /root/.ansible/tmp/ansible-local-8543Bm9eWG/tmpn4OyUE TO /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_copy.py
<127.0.0.1> EXEC /bin/sh -c ‘chmod u+x /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/ /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_copy.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘/opt/rh/python27/root/usr/bin/python2 /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/AnsiballZ_copy.py && sleep 0’
<127.0.0.1> EXEC /bin/sh -c ‘rm -f -r /root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/ > /dev/null 2>&1 && sleep 0’
fatal: [localhost]: FAILED! => {
“changed”: false,
“checksum”: “1f4ebaebaf1be3adbe5f2c2c9b4bf1bf84c9ce9a”,
“diff”: ,
“invocation”: {
“module_args”: {
“_original_basename”: “nic.ps1.j2”,
“attributes”: null,
“backup”: false,
“checksum”: “1f4ebaebaf1be3adbe5f2c2c9b4bf1bf84c9ce9a”,
“content”: null,
“delimiter”: null,
“dest”: “/root/script.ps1”,
“directory_mode”: null,
“follow”: false,
“force”: true,
“group”: null,
“local_follow”: null,
“mode”: null,
“owner”: null,
“regexp”: null,
“remote_src”: null,
“selevel”: null,
“serole”: null,
“setype”: null,
“seuser”: null,
“src”: “/root/.ansible/tmp/ansible-tmp-1596839965.56-8623-255860923309448/source”,
“unsafe_writes”: null,
“validate”: null
}
},
“msg”: “Aborting, target uses selinux but python bindings (libselinux-python) aren’t installed!”
}

It appears as though you are using an SCL python:

/opt/rh/python27/root/usr/bin/python2

The libselinux-python package is not available to the SCL, and selinux python bindings are not provided for SCLs.

i fixed the issue

i removed below entry from the var file:

ansible_python_interpreter: ‘/opt/rh/python27/root/usr/bin/python2’

Thank you