From eb31faa7f5d146c9eb310def7a6849397a8184f0 Mon Sep 17 00:00:00 2001 From: jctanner Date: Mon, 2 May 2016 11:29:35 -0400 Subject: [PATCH] =?UTF-8?q?Remove=20the=20ziploader=20provided=20pythonpat?= =?UTF-8?q?hs=20from=20the=20env=20inside=20run=5Fcom=E2=80=A6=20(#15674)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove the ziploader provided pythonpaths from the env inside run_command. Fixes #15655 --- lib/ansible/module_utils/basic.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 10ae75ac808..a8356d95a79 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1971,6 +1971,19 @@ class AnsibleModule(object): old_env_vals['PATH'] = os.environ['PATH'] os.environ['PATH'] = "%s:%s" % (path_prefix, os.environ['PATH']) + # If using test-module and explode, the remote lib path will resemble ... + # /tmp/test_module_scratch/debug_dir/ansible/module_utils/basic.py + # If using ansible or ansible-playbook with a remote system ... + # /tmp/ansible_vmweLQ/ansible_modlib.zip/ansible/module_utils/basic.py + + # Clean out python paths set by ziploader + if 'PYTHONPATH' in os.environ: + pypaths = os.environ['PYTHONPATH'].split(':') + pypaths = [x for x in pypaths \ + if not x.endswith('/ansible_modlib.zip') \ + and not x.endswith('/debug_dir')] + os.environ['PYTHONPATH'] = ':'.join(pypaths) + # create a printable version of the command for use # in reporting later, which strips out things like # passwords from the args list @@ -2012,7 +2025,6 @@ class AnsibleModule(object): stdin=st_in, stdout=subprocess.PIPE, stderr=subprocess.PIPE, - env=os.environ, ) if cwd and os.path.isdir(cwd):