Browse Source

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
changes/13/633513/1
Jesse Pretorius 4 months ago
parent
commit
03aa9c1e2b
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      test-ansible-env-prep.sh

+ 9
- 0
test-ansible-env-prep.sh View File

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

Loading…
Cancel
Save