mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Iterate through role paths when installing roles (#17487)
* Iterate through role paths when attempting to install roles
This commit is contained in:
parent
e8897a9b91
commit
af2ce7725b
1 changed files with 43 additions and 29 deletions
|
@ -79,6 +79,9 @@ class GalaxyRole(object):
|
||||||
else:
|
else:
|
||||||
# use the first path by default
|
# use the first path by default
|
||||||
self.path = os.path.join(galaxy.roles_paths[0], self.name)
|
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):
|
def __eq__(self, other):
|
||||||
return self.name == other.name
|
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
|
# 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
|
# the tar file here, since the default is 'github_repo-target', and change it
|
||||||
# to the specified role's name
|
# to the specified role's name
|
||||||
|
installed = False
|
||||||
|
while not installed:
|
||||||
display.display("- extracting %s to %s" % (self.name, self.path))
|
display.display("- extracting %s to %s" % (self.name, self.path))
|
||||||
try:
|
try:
|
||||||
if os.path.exists(self.path):
|
if os.path.exists(self.path):
|
||||||
|
@ -291,7 +296,16 @@ class GalaxyRole(object):
|
||||||
|
|
||||||
# write out the install info file for later use
|
# write out the install info file for later use
|
||||||
self._write_galaxy_install_info()
|
self._write_galaxy_install_info()
|
||||||
|
installed = True
|
||||||
except OSError as e:
|
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)))
|
raise AnsibleError("Could not update files in %s: %s" % (self.path, str(e)))
|
||||||
|
|
||||||
# return the parsed yaml metadata
|
# return the parsed yaml metadata
|
||||||
|
|
Loading…
Reference in a new issue