Ensure selinux bindings are linked into the venv

When running role tests, the tox venv does not have the selinux
bindings, and they are not installable via pip. To ensure that
Ansible is able to use the file module which requires these
bindings, we symlink them into the venv.

Change-Id: Ie8426653b4843fdae0946a49c02fa11db139fd4e
This commit is contained in:
Jesse Pretorius 2019-01-28 14:39:13 +00:00
parent 6223a72d18
commit 03aa9c1e2b
1 changed files with 9 additions and 0 deletions

View File

@ -231,3 +231,12 @@ fi
# Setup ARA
setup_ara
# Ensure that SElinux bindings are linked into the venv
source /etc/os-release || source /usr/lib/os-release
if [[ ${ID,,} =~ (centos|rhel|fedora) ]]; then
PYTHON_FOLDER=$(find ${VIRTUAL_ENV}/lib -maxdepth 1 -type d -name "python*")
SELINUX_FOLDER=$(rpm -ql libselinux-python | egrep '^.*python2.7.*/(site|dist)-packages/selinux$')
echo "RHEL variant found. Linking ${PYTHON_FOLDER}/site-packages/selinux to ${SELINUX_FOLDER}..."
ln -sfn ${SELINUX_FOLDER} ${PYTHON_FOLDER}/site-packages/selinux
fi