Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the ziploader provided pythonpaths from the env inside run_com… #15674

Merged
merged 8 commits into from
May 2, 2016
14 changes: 13 additions & 1 deletion lib/ansible/module_utils/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,19 @@ def run_command(self, args, check_rc=False, close_fds=True, executable=None, dat
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
Expand Down Expand Up @@ -2016,7 +2029,6 @@ def run_command(self, args, check_rc=False, close_fds=True, executable=None, dat
stdin=st_in,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
env=os.environ,
)

if cwd and os.path.isdir(cwd):
Expand Down