mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-23 10:51:24 -07:00
let chdir support relative path in more modules (#16736)
This commit is contained in:
parent
28b4931e3d
commit
d9e1e374b2
2 changed files with 15 additions and 4 deletions
|
@ -2311,14 +2311,13 @@ class AnsibleModule(object):
|
|||
stderr=subprocess.PIPE,
|
||||
)
|
||||
|
||||
if cwd and os.path.isdir(cwd):
|
||||
kwargs['cwd'] = cwd
|
||||
|
||||
# store the pwd
|
||||
prev_dir = os.getcwd()
|
||||
|
||||
# make sure we're in the right working directory
|
||||
if cwd and os.path.isdir(cwd):
|
||||
cwd = os.path.abspath(os.path.expanduser(cwd))
|
||||
kwargs['cwd'] = cwd
|
||||
try:
|
||||
os.chdir(cwd)
|
||||
except (OSError, IOError):
|
||||
|
@ -2330,7 +2329,6 @@ class AnsibleModule(object):
|
|||
old_umask = os.umask(umask)
|
||||
|
||||
try:
|
||||
|
||||
if self._debug:
|
||||
self.log('Executing: ' + clean_args)
|
||||
cmd = subprocess.Popen(args, **kwargs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue