diff --git a/changelogs/fragments/ansible-test-env-alteration.yml b/changelogs/fragments/ansible-test-env-alteration.yml new file mode 100644 index 00000000000..2bd28d0d31e --- /dev/null +++ b/changelogs/fragments/ansible-test-env-alteration.yml @@ -0,0 +1,2 @@ +bugfixes: + - ansible-test now properly uses a fresh copy of environment variables for each command invocation to avoid mixing vars between commands diff --git a/test/lib/ansible_test/_internal/util_common.py b/test/lib/ansible_test/_internal/util_common.py index f4035ee9344..5be20ee749f 100644 --- a/test/lib/ansible_test/_internal/util_common.py +++ b/test/lib/ansible_test/_internal/util_common.py @@ -335,6 +335,8 @@ def intercept_command(args, cmd, target_name, env, capture=False, data=None, cwd """ if not env: env = common_environment() + else: + env = env.copy() cmd = list(cmd) version = python_version or args.python_version