From 03aa9c1e2b08823949511a1f0dbecdfaffb0b8e2 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 28 Jan 2019 14:39:13 +0000 Subject: [PATCH] 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 --- test-ansible-env-prep.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test-ansible-env-prep.sh b/test-ansible-env-prep.sh index c18ac3cf..378f132a 100755 --- a/test-ansible-env-prep.sh +++ b/test-ansible-env-prep.sh @@ -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