Empty meta role file makes publish to galaxy fail

Using an empty role/role_name/meta/main.yml file in a collection makes galaxy to fail importing the collection when publishing

This is an example of a failed task importing the collection to be published:

https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e5752-8972-7202-b02d-c7798f4e3a0e/

The error is not quite clear but is complaining on meta fields of a role.

    "error": {
        "traceback": "  File \"/venv/lib64/python3.11/site-packages/pulpcore/tasking/tasks.py\", line 66, in _execute_task\n    result = func(*args, **kwargs)\n             ^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/galaxy_ng/app/tasks/publishing.py\", line 115, in import_and_auto_approve\n    repo = _upload_collection(**kwargs)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/app/galaxy_ng/app/tasks/publishing.py\", line 65, in _upload_collection\n    general_create(*general_args, **kwargs)\n  File \"/venv/lib64/python3.11/site-packages/pulpcore/app/tasks/base.py\", line 37, in general_create\n    serializer.is_valid(raise_exception=True)\n  File \"/venv/lib64/python3.11/site-packages/rest_framework/serializers.py\", line 227, in is_valid\n    self._validated_data = self.run_validation(self.initial_data)\n                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/rest_framework/serializers.py\", line 429, in run_validation\n    value = self.validate(value)\n            ^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py\", line 484, in validate\n    return super().validate(data)\n           ^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/pulpcore/plugin/serializers/content.py\", line 123, in validate\n    data = self.deferred_validate(data)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/serializers.py\", line 494, in deferred_validate\n    collection_info = process_collection_artifact(\n                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/pulp_ansible/app/tasks/upload.py\", line 37, in process_collection_artifact\n    importer_result = import_collection(\n                      ^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py\", line 78, in import_collection\n    return _import_collection(file, filename, file_url, logger, cfg)\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/collection.py\", line 135, in _import_collection\n    data = CollectionLoader(extract_dir, filename, cfg=cfg, logger=logger).load()\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/collection.py\", line 100, in load\n    self.content_objs = list(self._load_contents())\n                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/collection.py\", line 378, in _load_contents\n    content_obj = loader.load()\n                  ^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/content.py\", line 180, in load\n    description = self._get_metadata_description()\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/venv/lib64/python3.11/site-packages/galaxy_importer/loaders/content.py\", line 220, in _get_metadata_description\n    description = role_metadata[\"galaxy_info\"][\"description\"]\n                  ~~~~~~~~~~~~~^^^^^^^^^^^^^^^\n",
        "description": "'NoneType' object is not subscriptable"
    },

Later, it was found that empty meta causes it to fail, removing it allows the import of collection to complete and be published as in this test:

https://galaxy.ansible.com/api/v3/plugin/ansible/imports/collections/018e632a-b646-7e94-8d07-ba2da3d7369b/

Is there any documentation available on the requirements of meta files for a role?

Thanks!

According to this page:

the Galaxy Roles document… explains the required metadata your role needs for use in Galaxy https://galaxy.ansible.com/docs/contributing/creating_role.html.

However that now redirects to https://galaxy.ansible.com/ui/ but the Internet Archive has a copy and “the default metadata file created by the init command”:

galaxy_info:
  role_name: foo
  author: your name
  description: your description
  company: your company (optional)

  # If the issue tracker for your role is not on github, uncomment the
  # next line and provide a value
  # issue_tracker_url: http://example.com/issue/tracker

  # Some suggested licenses:
  # - BSD (default)
  # - MIT
  # - GPLv2
  # - GPLv3
  # - Apache
  # - CC-BY
  license: license (GPLv2, CC-BY, etc)

  min_ansible_version: 1.2

  # If this a Container Enabled role, provide the minimum Ansible Container version.
  # min_ansible_container_version:

  # Optionally specify the branch Galaxy will use when accessing the GitHub
  # repo for this role. During role install, if no tags are available,
  # Galaxy will use this branch. During import Galaxy will access files on
  # this branch. If Travis integration is configured, only notifications for this
  # branch will be accepted. Otherwise, in all cases, the repo's default branch
  # (usually master) will be used.
  #github_branch:

  #
  # platforms is a list of platforms, and each platform has a name and a list of versions.
  #
  # platforms:
  # - name: Fedora
  #   versions:
  #   - all
  #   - 25
  # - name: SomePlatform
  #   versions:
  #   - all
  #   - 1.0
  #   - 7
  #   - 99.99

  galaxy_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 tags to this list.
    #
    # NOTE: A tag is limited 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 to this list.
1 Like

Thanks for the info @chris it is quite useful for the parameters used in there.

While reading the Roles — Ansible Community Documentation it seems like the parameters are optional :thinking:

Role dependencies are stored in the meta/main.yml file within the role directory. This file should contain a list of roles and parameters to insert before the specified role.

I wonder if it should mention to not include empty files to avoid the problem we experienced when attempting to publish in galaxy. It took us a good amount of time to figure out the problem was an empty file. Or, if it should be reported as a bug in the import process of galaxy.

1 Like