only change dir to playdir if local
fixes #17869
fixes #17770
(cherry picked from commit 49ce0c8bac
)
This commit is contained in:
parent
ec1f19ac3a
commit
751865d68c
1 changed files with 6 additions and 4 deletions
|
@ -735,12 +735,14 @@ 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()
|
||||
# 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:
|
||||
if self._connection.transport == 'local':
|
||||
os.chdir(cwd)
|
||||
|
||||
# stdout and stderr may be either a file-like or a bytes object.
|
||||
|
|
Loading…
Reference in a new issue