diff --git a/lib/ansible/cli/galaxy.py b/lib/ansible/cli/galaxy.py index 8ec0d0f057a..ae3e38959f5 100644 --- a/lib/ansible/cli/galaxy.py +++ b/lib/ansible/cli/galaxy.py @@ -85,9 +85,9 @@ class GalaxyCLI(CLI): elif self.action == "search": self.parser.add_option('-P', '--platforms', dest='platforms', help='list of OS platforms to filter by') - self.parser.add_option('-C', '--categories', dest='categories', - help='list of categories to filter by') - self.parser.set_usage("usage: %prog search [] [-C ] [-P platform]") + self.parser.add_option('-T', '--tags', dest='tags', + help='list of tags to filter by') + self.parser.set_usage("usage: %prog search [] [-T ] [-P platform]") # options that apply to more than one action if self.action != "init": @@ -99,6 +99,8 @@ class GalaxyCLI(CLI): if self.action in ("info","init","install","search"): self.parser.add_option('-s', '--server', dest='api_server', default="https://galaxy.ansible.com", help='The API server destination') + self.parser.add_option('-c', '--ignore-certs', action='store_false', dest='validate_certs', default=True, + help='Ignore SSL certificate validation errors.') if self.action in ("init","install"): self.parser.add_option('-f', '--force', dest='force', action='store_true', default=False, @@ -251,9 +253,6 @@ class GalaxyCLI(CLI): platforms = [] if not offline and self.api: platforms = self.api.get_list("platforms") or [] - categories = [] - if not offline and self.api: - categories = self.api.get_list("categories") or [] # group the list of platforms from the api based # on their names, with the release field being @@ -270,7 +269,6 @@ class GalaxyCLI(CLI): issue_tracker_url = 'http://example.com/issue/tracker', min_ansible_version = '1.2', platforms = platform_groups, - categories = categories, ) rendered_meta = Environment().from_string(self.galaxy.default_meta).render(inject) f = open(main_yml_path, 'w') @@ -543,7 +541,7 @@ class GalaxyCLI(CLI): elif len(self.args) == 1: search = self.args.pop() - response = self.api.search_roles(search, self.options.platforms, self.options.categories) + response = self.api.search_roles(search, self.options.platforms, self.options.tags) if 'count' in response: self.galaxy.display.display("Found %d roles matching your search:\n" % response['count']) diff --git a/lib/ansible/galaxy/api.py b/lib/ansible/galaxy/api.py index 43d378e0a74..5b67d9d6c92 100644 --- a/lib/ansible/galaxy/api.py +++ b/lib/ansible/galaxy/api.py @@ -62,7 +62,7 @@ class GalaxyAPI(object): return 'v1' try: - data = json.load(open_url(api_server)) + data = json.load(open_url(api_server, validate_certs=self.galaxy.options.validate_certs)) return data.get("current_version", 'v1') except Exception as e: # TODO: report error @@ -86,7 +86,7 @@ class GalaxyAPI(object): url = '%s/roles/?owner__username=%s&name=%s' % (self.baseurl, user_name, role_name) self.galaxy.display.vvvv("- %s" % (url)) try: - data = json.load(open_url(url)) + data = json.load(open_url(url, validate_certs=self.galaxy.options.validate_certs)) if len(data["results"]) != 0: return data["results"][0] except: @@ -103,13 +103,13 @@ class GalaxyAPI(object): try: url = '%s/roles/%d/%s/?page_size=50' % (self.baseurl, int(role_id), related) - data = json.load(open_url(url)) + data = json.load(open_url(url, validate_certs=self.galaxy.options.validate_certs)) results = data['results'] done = (data.get('next', None) == None) while not done: url = '%s%s' % (self.baseurl, data['next']) self.galaxy.display.display(url) - data = json.load(open_url(url)) + data = json.load(open_url(url, validate_certs=self.galaxy.options.validate_certs)) results += data['results'] done = (data.get('next', None) == None) return results @@ -123,7 +123,7 @@ class GalaxyAPI(object): try: url = '%s/%s/?page_size' % (self.baseurl, what) - data = json.load(open_url(url)) + data = json.load(open_url(url, validate_certs=self.galaxy.options.validate_certs)) if "results" in data: results = data['results'] else: @@ -134,27 +134,27 @@ class GalaxyAPI(object): while not done: url = '%s%s' % (self.baseurl, data['next']) self.galaxy.display.display(url) - data = json.load(open_url(url)) + data = json.load(open_url(url, validate_certs=self.galaxy.options.validate_certs)) results += data['results'] done = (data.get('next', None) == None) return results except Exception as error: raise AnsibleError("Failed to download the %s list: %s" % (what, str(error))) - def search_roles(self, search, platforms=None, categories=None): + def search_roles(self, search, platforms=None, tags=None): search_url = self.baseurl + '/roles/?page=1' if search: search_url += '&search=' + urlquote(search) - if categories is None: - categories = [] - elif isinstance(categories, basestring): - categories = categories.split(',') + if tags is None: + tags = [] + elif isinstance(tags, basestring): + tags = tags.split(',') - for cat in categories: - search_url += '&chain__categories__name=' + urlquote(cat) + for tag in tags: + search_url += '&chain__tags__name=' + urlquote(tag) if platforms is None: platforms = [] @@ -166,7 +166,7 @@ class GalaxyAPI(object): self.galaxy.display.debug("Executing query: %s" % search_url) try: - data = json.load(open_url(search_url)) + data = json.load(open_url(search_url, validate_certs=self.galaxy.options.validate_certs)) except HTTPError as e: raise AnsibleError("Unsuccessful request to server: %s" % str(e)) diff --git a/lib/ansible/galaxy/data/metadata_template.j2 b/lib/ansible/galaxy/data/metadata_template.j2 index 9b4e922ff40..cd2e7f53cd6 100644 --- a/lib/ansible/galaxy/data/metadata_template.j2 +++ b/lib/ansible/galaxy/data/metadata_template.j2 @@ -28,14 +28,15 @@ galaxy_info: # - {{ version }} {%- endfor %} {%- endfor %} - # - # Below are all categories currently available. Just as with - # the platforms above, uncomment those that apply to your role. - # - #categories: - {%- for category in categories %} - #- {{ category.name }} - {%- endfor %} + tags: [] + # List tags for your role here, one per line. A tag is + # a keyword that describes and categorizes the role. + # Users find roles by searching for tags. Be sure to + # remove the '[]' above if you add dependencies + # to this list. + # + # NOTE: A tag is limted to a single word comprised of + # alphanumeric characters. Maximum 20 tags per role. dependencies: [] # List your role dependencies here, one per line. # Be sure to remove the '[]' above if you add dependencies