diff --git a/test/integration/targets/filters/runme.sh b/test/integration/targets/filters/runme.sh index e1e1333cac..d2a38f5900 100755 --- a/test/integration/targets/filters/runme.sh +++ b/test/integration/targets/filters/runme.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -ex -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv" -source "${OUTPUT_DIR}/venv/bin/activate" set -eux +source virtualenv.sh + # Requirements have to be installed prior to running ansible-playbook # because plugins and requirements are loaded before the task runs diff --git a/test/integration/targets/groupby_filter/runme.sh b/test/integration/targets/groupby_filter/runme.sh index f65cc008f6..e5099aa1b7 100755 --- a/test/integration/targets/groupby_filter/runme.sh +++ b/test/integration/targets/groupby_filter/runme.sh @@ -1,15 +1,8 @@ #!/usr/bin/env bash -# We don't set -u here, due to pypa/virtualenv#150 -set -ex +set -eux -MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') - -trap 'rm -rf "${MYTMPDIR}"' EXIT - -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${MYTMPDIR}/jinja2" - -source "${MYTMPDIR}/jinja2/bin/activate" +source virtualenv.sh pip install -U jinja2==2.9.4 diff --git a/test/integration/targets/inventory_aws_conformance/runme.sh b/test/integration/targets/inventory_aws_conformance/runme.sh index c4208d1fdf..a57e13ec39 100755 --- a/test/integration/targets/inventory_aws_conformance/runme.sh +++ b/test/integration/targets/inventory_aws_conformance/runme.sh @@ -1,9 +1,9 @@ #!/usr/bin/env bash -set -ex +set -eux + +source virtualenv.sh -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER:-python}" "${OUTPUT_DIR}/aws-ec2-inventory" -source "${OUTPUT_DIR}/aws-ec2-inventory/bin/activate" pip install "python-dateutil>=2.1,<2.7.0" jmespath "Jinja2>=2.10" PyYaml cryptography paramiko # create boto3 symlinks diff --git a/test/integration/targets/lookups/runme.sh b/test/integration/targets/lookups/runme.sh index a54fbfd4a8..77a73b9975 100755 --- a/test/integration/targets/lookups/runme.sh +++ b/test/integration/targets/lookups/runme.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -set -ex -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv" -source "${OUTPUT_DIR}/venv/bin/activate" set -eux +source virtualenv.sh + # Requirements have to be installed prior to running ansible-playbook # because plugins and requirements are loaded before the task runs pip install passlib diff --git a/test/integration/targets/template_jinja2_latest/runme.sh b/test/integration/targets/template_jinja2_latest/runme.sh index 88df296224..78dcf36fcd 100755 --- a/test/integration/targets/template_jinja2_latest/runme.sh +++ b/test/integration/targets/template_jinja2_latest/runme.sh @@ -1,15 +1,8 @@ #!/usr/bin/env bash -# We don't set -u here, due to pypa/virtualenv#150 -set -ex +set -eux -MYTMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir') - -trap 'rm -rf "${MYTMPDIR}"' EXIT - -virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${MYTMPDIR}/jinja2" - -source "${MYTMPDIR}/jinja2/bin/activate" +source virtualenv.sh pip install -U jinja2 diff --git a/test/runner/injector/virtualenv.sh b/test/runner/injector/virtualenv.sh new file mode 100644 index 0000000000..c6633a2521 --- /dev/null +++ b/test/runner/injector/virtualenv.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +# Create and activate a fresh virtual environment with `source virtualenv.sh`. + +rm -rf "${OUTPUT_DIR}/venv" +"${ANSIBLE_TEST_PYTHON_INTERPRETER}" -m virtualenv --system-site-packages --python "${ANSIBLE_TEST_PYTHON_INTERPRETER}" "${OUTPUT_DIR}/venv"