From 0e16a5f3ee9b8c7e931b860f7790ea9a6197651b Mon Sep 17 00:00:00 2001 From: Will Thames Date: Thu, 7 Jul 2016 02:28:54 +1000 Subject: [PATCH] Retain local tar.gz roles during galaxy install (#16592) Don't treat local tar.gz files as temporary when cleaning up at the end of an ansible-galaxy install --- lib/ansible/galaxy/role.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/ansible/galaxy/role.py b/lib/ansible/galaxy/role.py index 2d52913efd..6b617ecf19 100644 --- a/lib/ansible/galaxy/role.py +++ b/lib/ansible/galaxy/role.py @@ -188,6 +188,7 @@ class GalaxyRole(object): def install(self): # the file is a tar, so open it that way and extract it # to the specified (or default) roles directory + local_file = False if self.scm: # create tar file from scm url @@ -195,6 +196,7 @@ class GalaxyRole(object): elif self.src: if os.path.isfile(self.src): # installing a local tar.gz + local_file = True tmp_file = self.src elif '://' in self.src: role_data = self.src @@ -294,10 +296,11 @@ class GalaxyRole(object): # return the parsed yaml metadata display.display("- %s was installed successfully" % self.name) - try: - os.unlink(tmp_file) - except (OSError,IOError) as e: - display.warning("Unable to remove tmp file (%s): %s" % (tmp_file, str(e))) + if not local_file: + try: + os.unlink(tmp_file) + except (OSError,IOError) as e: + display.warning("Unable to remove tmp file (%s): %s" % (tmp_file, str(e))) return True return False