mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
set cwd to task's basedir (#16805)
* switch cwd to basedir of task This restores previous behaviour in pre 2.0 and allows for 'local type' plugins and actions to have a more predictable relative path. fixes #14489 * removed FIXME since prev commit 'fixes' this * fix tests, now they need a loader (thanks jimi!)
This commit is contained in:
parent
363596c67f
commit
e2f17f8d9b
3 changed files with 11 additions and 3 deletions
|
@ -718,7 +718,14 @@ class ActionBase(with_metaclass(ABCMeta, object)):
|
|||
cmd = executable + ' -c ' + pipes.quote(cmd)
|
||||
|
||||
display.debug("_low_level_execute_command(): executing: %s" % (cmd,))
|
||||
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||
|
||||
# Change directory to basedir of task for command execution
|
||||
cwd = os.getcwd()
|
||||
os.chdir(self._loader.get_basedir())
|
||||
try:
|
||||
rc, stdout, stderr = self._connection.exec_command(cmd, in_data=in_data, sudoable=sudoable)
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
# stdout and stderr may be either a file-like or a bytes object.
|
||||
# Convert either one to a text type
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue