diff options
author | Brian Coca <brian.coca+git@gmail.com> | 2016-10-03 08:42:32 -0400 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2016-10-03 08:44:25 -0400 |
commit | 49ce0c8baccbec45156b8a1ecb5c1d496180ed43 (patch) | |
tree | 957bedbaa3f9cbf5c49b721a69952b26450b9d3f | |
parent | 5bc3cb278cf700be6e460453ec8e4b5b6c2e804b (diff) | |
download | ansible-49ce0c8baccbec45156b8a1ecb5c1d496180ed43.tar.gz |
only change dir to playdir if local
fixes #17869
fixes #17770
-rw-r--r-- | lib/ansible/plugins/action/__init__.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ansible/plugins/action/__init__.py b/lib/ansible/plugins/action/__init__.py index 75aa5c0fd3..7b5940d2ff 100644 --- a/lib/ansible/plugins/action/__init__.py +++ b/lib/ansible/plugins/action/__init__.py @@ -719,13 +719,15 @@ class ActionBase(with_metaclass(ABCMeta, object)): display.debug("_low_level_execute_command(): executing: %s" % (cmd,)) - # Change directory to basedir of task for command execution - cwd = os.getcwd() - os.chdir(self._loader.get_basedir()) + # Change directory to basedir of task for command execution when connection is local + if self._connection.transport == 'local': + os.chdir(self._loader.get_basedir()) + cwd = os.getcwd() try: rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable) finally: - os.chdir(cwd) + if self._connection.transport == 'local': + os.chdir(cwd) # stdout and stderr may be either a file-like or a bytes object. # Convert either one to a text type |