|
|
@ -460,45 +460,46 @@ class GalaxyCLI(CLI):
|
|
|
|
if len(self.args) > 1:
|
|
|
|
if len(self.args) > 1:
|
|
|
|
raise AnsibleOptionsError("- please specify only one role to list, or specify no roles to see a full list")
|
|
|
|
raise AnsibleOptionsError("- please specify only one role to list, or specify no roles to see a full list")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _display_role(gr):
|
|
|
|
|
|
|
|
install_info = gr.install_info
|
|
|
|
|
|
|
|
version = None
|
|
|
|
|
|
|
|
if install_info:
|
|
|
|
|
|
|
|
version = install_info.get("version", None)
|
|
|
|
|
|
|
|
if not version:
|
|
|
|
|
|
|
|
version = "(unknown version)"
|
|
|
|
|
|
|
|
display.display("- %s, %s" % (gr.name, version))
|
|
|
|
|
|
|
|
|
|
|
|
if len(self.args) == 1:
|
|
|
|
if len(self.args) == 1:
|
|
|
|
# show only the request role, if it exists
|
|
|
|
# show the requested role, if it exists
|
|
|
|
name = self.args.pop()
|
|
|
|
name = self.args.pop()
|
|
|
|
gr = GalaxyRole(self.galaxy, name)
|
|
|
|
gr = GalaxyRole(self.galaxy, name)
|
|
|
|
if gr.metadata:
|
|
|
|
if gr.metadata:
|
|
|
|
install_info = gr.install_info
|
|
|
|
display.display('# %s' % os.path.dirname(gr.path))
|
|
|
|
version = None
|
|
|
|
_display_role(gr)
|
|
|
|
if install_info:
|
|
|
|
|
|
|
|
version = install_info.get("version", None)
|
|
|
|
|
|
|
|
if not version:
|
|
|
|
|
|
|
|
version = "(unknown version)"
|
|
|
|
|
|
|
|
# show some more info about single roles here
|
|
|
|
|
|
|
|
display.display("- %s, %s" % (name, version))
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
display.display("- the role %s was not found" % name)
|
|
|
|
display.display("- the role %s was not found" % name)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# show all valid roles in the roles_path directory
|
|
|
|
# show all valid roles in the roles_path directory
|
|
|
|
roles_path = self.options.roles_path
|
|
|
|
roles_path = self.options.roles_path
|
|
|
|
path_found = False
|
|
|
|
path_found = False
|
|
|
|
|
|
|
|
warnings = []
|
|
|
|
for path in roles_path:
|
|
|
|
for path in roles_path:
|
|
|
|
role_path = os.path.expanduser(path)
|
|
|
|
role_path = os.path.expanduser(path)
|
|
|
|
if not os.path.exists(role_path):
|
|
|
|
if not os.path.exists(role_path):
|
|
|
|
display.warning("- the configured path %s does not exist." % role_path)
|
|
|
|
warnings.append("- the configured path %s does not exist." % role_path)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
elif not os.path.isdir(role_path):
|
|
|
|
elif not os.path.isdir(role_path):
|
|
|
|
display.warning("- the configured path %s, exists, but it is not a directory." % role_path)
|
|
|
|
warnings.append("- the configured path %s, exists, but it is not a directory." % role_path)
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
|
|
|
|
display.display('# %s' % role_path)
|
|
|
|
path_files = os.listdir(role_path)
|
|
|
|
path_files = os.listdir(role_path)
|
|
|
|
path_found = True
|
|
|
|
path_found = True
|
|
|
|
for path_file in path_files:
|
|
|
|
for path_file in path_files:
|
|
|
|
gr = GalaxyRole(self.galaxy, path_file, path=path)
|
|
|
|
gr = GalaxyRole(self.galaxy, path_file, path=path)
|
|
|
|
if gr.metadata:
|
|
|
|
if gr.metadata:
|
|
|
|
install_info = gr.install_info
|
|
|
|
_display_role(gr)
|
|
|
|
version = None
|
|
|
|
for w in warnings:
|
|
|
|
if install_info:
|
|
|
|
display.warning(w)
|
|
|
|
version = install_info.get("version", None)
|
|
|
|
|
|
|
|
if not version:
|
|
|
|
|
|
|
|
version = "(unknown version)"
|
|
|
|
|
|
|
|
display.display("- %s, %s" % (path_file, version))
|
|
|
|
|
|
|
|
if not path_found:
|
|
|
|
if not path_found:
|
|
|
|
raise AnsibleOptionsError("- None of the provided paths was usable. Please specify a valid path with --roles-path")
|
|
|
|
raise AnsibleOptionsError("- None of the provided paths was usable. Please specify a valid path with --roles-path")
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|