make individual bad paths a warning

still error if none of the paths provided was usable

fixes #39044
pull/39195/head
Brian Coca 7 years ago committed by Brian Coca
parent 0fef3f1b48
commit e4dbabbef2

@ -478,13 +478,17 @@ class GalaxyCLI(CLI):
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
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):
raise AnsibleOptionsError("- the path %s does not exist. Please specify a valid path with --roles-path" % role_path) display.warning("- the configured path %s does not exist." % role_path)
continue
elif not os.path.isdir(role_path): elif not os.path.isdir(role_path):
raise AnsibleOptionsError("- %s exists, but it is not a directory. Please specify a valid path with --roles-path" % role_path) display.warning("- the configured path %s, exists, but it is not a directory." % role_path)
continue
path_files = os.listdir(role_path) path_files = os.listdir(role_path)
path_found = True
for path_file in path_files: for path_file in path_files:
gr = GalaxyRole(self.galaxy, path_file) gr = GalaxyRole(self.galaxy, path_file)
if gr.metadata: if gr.metadata:
@ -495,6 +499,8 @@ class GalaxyCLI(CLI):
if not version: if not version:
version = "(unknown version)" version = "(unknown version)"
display.display("- %s, %s" % (path_file, version)) display.display("- %s, %s" % (path_file, version))
if not path_found:
raise AnsibleOptionsError("- None of the provided paths was usable. Please specify a valid path with --roles-path")
return 0 return 0
def execute_search(self): def execute_search(self):

Loading…
Cancel
Save