Skip to content

ansible-lint requires "repository" key to exist in "galaxy.yml" although "repository" is not syntactically required. #4793

@stopendy

Description

@stopendy
Summary

ansible-lint raises an error with "very high" severity if galaxy.yml doesn't have a repository key.

As Collection Galaxy metadata structure says, repository key is not required. Thus ansible-lint should not detect schema[galaxy] rule violation, which is mandatory. It can raise galaxy[xxx] rule with less severity.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
# ansible-lint 25.9.0 using ansible-core:2.19.2 ansible-compat:25.8.1 ruamel-yaml:0.18.15 ruamel-yaml-clib:0.2.14
  • OS: Fedora release 42 (Adams)
  • ansible installation method: one of source, pip
  • ansible-lint installation method: one of source, pip
STEPS TO REPRODUCE
  1. Create galaxy.yml as below.
namespace: local
name: test
description: ''

version: 0.0.1

readme: README.md
authors:
  - nobody
  1. Validate the galaxy.yml with ansible-lint.
ansible-lint galaxy.yml 
python3 -m venv venv
source venv/bin/activate
pip install ansible-core ansible-lint

cat << 'EOF' > galaxy.yml
namespace: local
name: test
description: ''

version: 0.0.1

readme: README.md
authors:
  - nobody
EOF

ansible-lint galaxy.yml
Desired Behavior

ansible-lint should not report schema[galaxy] because galaxy.yml provided above is syntactically correct.

Actual Behavior

ansible-lint galaxy.yml reported schema[galaxy] rule violation.

ansible-lint galaxy.yml
# WARNING  Project directory /.ansible cannot be used for caching as it is not writable.
# WARNING  Using unique temporary directory /tmp/.ansible-0aaa for caching.
# WARNING  Listing 5 violation(s) that are fatal
# galaxy[no-changelog]: No changelog found. Please add a changelog file. Refer to the galaxy.md file for more info.
# galaxy.yml:1

# galaxy[tags]: galaxy.yaml must have one of the required tags: ['application', 'cloud', 'database', 'eda', 'infrastructure', 'linux', 'monitoring', 'networking', 'security', 'storage', 'tools', 'windows']
# galaxy.yml:1

# galaxy[no-runtime]: meta/runtime.yml file not found.
# galaxy.yml:1

# schema[galaxy]: $ 'repository' is a required property. See https://docs.ansible.com/ansible/latest/dev_guide/collections_galaxy_meta.html
# galaxy.yml:1  Returned errors will not include exact line numbers, but they will mention
# the schema name being used as a tag, like ``schema[playbook]``,
# ``schema[tasks]``.

# This rule is not skippable and stops further processing of the file.

# If incorrect schema was picked, you might want to either:

# * move the file to standard location, so its file is detected correctly.
# * use ``kinds:`` option in linter config to help it pick correct file type.
# [/]

# yaml[empty-lines]: Too many blank lines (1 > 0)
# galaxy.yml:10

# Read documentation for instructions on how to ignore specific rule violations.

# # Rule Violation Summary

#   1 schema profile:basic tags:core
#   1 yaml profile:basic tags:formatting,yaml
#   1 galaxy profile:basic tags:metadata
#   1 galaxy profile:basic tags:metadata
#   1 galaxy profile:basic tags:metadata

# Failed: 5 failure(s), 0 warning(s) in 1 files processed of 1 encountered. Last profile that met the validation criteria was 'min'.
Impact on VS Code Ansible Extension

VS Code Ansible Extension raises Missing property "repository". error. This might look outstanding to Ansible extension users.

screenshot_vs_code_ansible_extension_error.png

YAML schema validation errors has high severity [1] and is mandatory [2], which I guess is why the error appears on the VS Code.

Proposal
  • repository key should be removed from required list in the schema galaxy.json.
  • I know repository key and license key are required in galaxy.yml to push to Ansible Galaxy. Thus we can add some rules to galaxy.py and galaxy.md such as galaxy[no-repository] and galaxy[no-license] in order to let developers write a better code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions