mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 19:31:26 -07:00
Correct usage for shutil.rmtree (#31541)
* Correct usage for shutil.rmtree Fix adds correct usage of shutil.rmtree in git module Fixes: #31225 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com> * Include archive tests so they get run * Use new include syntax * Cleanup syntax on git tests - use multi-line YAML - remove unneeded {{ }} around vars in conditionals - remove unneeded quotes - add task file name to task names for easier troubleshooting when things fail * Make archive tests work for RHEL/CentOS 6 The older versions of Jinja2 in RHEL/CentOS 6 required assertion tasks using the map filter to be skipped. The older version of git required gzip compression to be skipped on RHEL/CentOS 6. * Account for ansible_distribution_major_version missing
This commit is contained in:
parent
42deaf2c71
commit
a047fe0e4c
18 changed files with 385 additions and 314 deletions
|
@ -942,13 +942,13 @@ def create_archive(git_path, module, dest, archive, version, repo, result):
|
|||
result.update(changed=False)
|
||||
# Cleanup before exiting
|
||||
try:
|
||||
shutil.remove(tempdir)
|
||||
shutil.rmtree(tempdir)
|
||||
except OSError:
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
shutil.move(new_archive, archive)
|
||||
shutil.remove(tempdir)
|
||||
shutil.rmtree(tempdir)
|
||||
result.update(changed=True)
|
||||
except OSError as e:
|
||||
module.fail_json(msg="Failed to move %s to %s" %
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue