summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2017-08-01 06:31:19 -0700
committerToshio Kuratomi <a.badger@gmail.com>2017-08-01 15:21:21 -0700
commit25c95a96a825e734eb1c40d07970703a54fcc900 (patch)
tree3e3d173a3f52169d8d39592fe5cbb342fe45c2fa
parent46846b19731895f9c2a64f7790e1182dbfa89c9d (diff)
downloadansible-25c95a96a825e734eb1c40d07970703a54fcc900.tar.gz
Fix for ansiballz filenames conflicting with python stdlib modules
The AnsiBallZ wrapper is transferred to the remote machine with a filename similar to the Ansible-module it runs. For modules like copy and tempfile, this can end up conflicting with stdlib modules on the remote machine depending on how python is setup there. We have a little bit of code in the wrapper to deal with this by removing the path that the ansible module resides in from sys.path. On MacOSX, that code was having a problem. The path the module ends up in included a symlinked directory so we were looking for a path in sys.path but we had to look for the unsymlinked path instead. Fix that by using os.path.realpath() instead of os.path.abspath() (cherry picked from commit 15902f24966bb81cd56b7c9cf36396aa2c723a4f)
-rw-r--r--lib/ansible/executor/module_common.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/ansible/executor/module_common.py b/lib/ansible/executor/module_common.py
index 8d38951d70..d99caec378 100644
--- a/lib/ansible/executor/module_common.py
+++ b/lib/ansible/executor/module_common.py
@@ -121,11 +121,11 @@ import __main__
# stdlib module
scriptdir = None
try:
- scriptdir = os.path.dirname(os.path.abspath(__main__.__file__))
+ scriptdir = os.path.dirname(os.path.realpath(__main__.__file__))
except (AttributeError, OSError):
# Some platforms don't set __file__ when reading from stdin
# OSX raises OSError if using abspath() in a directory we don't have
- # permission to read.
+ # permission to read (realpath calls abspath)
pass
if scriptdir is not None:
sys.path = [p for p in sys.path if p != scriptdir]