Skip to content

Commit

Permalink
[v1.8.0][zos_job_submit] Removes tmp files left behind by zos_job_sub…
Browse files Browse the repository at this point in the history
…mit (#1070)

* Ensure proper cleanup for ansiballz

* Added proper removal of AnsiballZ
  • Loading branch information
fernandofloresg committed Nov 30, 2023
1 parent 44754ab commit ca15836
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions plugins/action/zos_job_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ def run(self, tmp=None, task_vars=None):
dest_path = self._execute_module(
module_name="tempfile", module_args={}, task_vars=task_vars,
).get("path")
# Calling execute_module from this step with tempfile leaves behind a tmpdir.
# This is called to ensure the proper removal.
tmpdir = self._connection._shell.tmpdir
if tmpdir:
self._remove_tmp_path(tmpdir)

result["failed"] = True
if source is None or dest_path is None:
Expand Down Expand Up @@ -178,14 +183,6 @@ def run(self, tmp=None, task_vars=None):
)
else:
result.update(dict(failed=True))
if rendered_file:
os.remove(rendered_file)
if os.path.isfile(tmp_src):
self._connection.exec_command("rm -rf {0}".format(tmp_src))
if os.path.isfile(dest_file):
self._connection.exec_command("rm -rf {0}".format(dest_file))
if os.path.isfile(source_full):
self._connection.exec_command("rm -rf {0}".format(source_full))

else:
result.update(
Expand Down

0 comments on commit ca15836

Please sign in to comment.