Iterate through role paths when installing roles (#17487)

* Iterate through role paths when attempting to install roles
This commit is contained in:
jctanner 2016-09-09 16:50:50 -04:00 committed by GitHub
parent e8897a9b91
commit af2ce7725b

View file

@ -79,6 +79,9 @@ class GalaxyRole(object):
else:
# use the first path by default
self.path = os.path.join(galaxy.roles_paths[0], self.name)
# create list of possible paths
self.paths = [x for x in galaxy.roles_paths]
self.paths = [os.path.join(x, self.name) for x in self.paths]
def __eq__(self, other):
return self.name == other.name
@ -261,6 +264,8 @@ class GalaxyRole(object):
# we strip off the top-level directory for all of the files contained within
# the tar file here, since the default is 'github_repo-target', and change it
# to the specified role's name
installed = False
while not installed:
display.display("- extracting %s to %s" % (self.name, self.path))
try:
if os.path.exists(self.path):
@ -291,7 +296,16 @@ class GalaxyRole(object):
# write out the install info file for later use
self._write_galaxy_install_info()
installed = True
except OSError as e:
error = True
if e[0] == 13 and len(self.paths) > 1:
current = self.paths.index(self.path)
nextidx = current + 1
if len(self.paths) >= current:
self.path = self.paths[nextidx]
error = False
if error:
raise AnsibleError("Could not update files in %s: %s" % (self.path, str(e)))
# return the parsed yaml metadata