Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliases unsupported in schema[role-arg-spec] #3656

Closed
nicolasbouchard-ubi opened this issue Aug 11, 2023 · 4 comments · Fixed by #3684
Closed

Aliases unsupported in schema[role-arg-spec] #3656

nicolasbouchard-ubi opened this issue Aug 11, 2023 · 4 comments · Fixed by #3684
Assignees
Labels

Comments

@nicolasbouchard-ubi
Copy link

nicolasbouchard-ubi commented Aug 11, 2023

Summary

When running ansible-lint against my scripts, I get this error: schema[role-arg-spec]: Additional properties are not allowed ('aliases' was unexpected)

But, running the validations passes in the playbook so surely the aliases has been taken into account because the argument is not named namespace.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.17.2 ansible 2.14.8
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE

Create a role with the following files:

defaults/main.yml
---
dictionary_root:
  dictionary_key1:
    arg1: "test_arg1"
    arg2: "test_arg2"


meta/argument_specs.yml
---
argument_specs:
  main:
    short_description: Entry point for role
    options:
      dictionary_root:
        type: dict
        required: true
        options:
          namespace:
            type: dict
            required: true
            aliases: ["dictionary_key1"]
            options:
              arg1:
                type: str
                required: true
              arg2:
                type: str
                required: true
Desired Behavior

The alisases is accepted as a valid attribute by ansible-lint.

Actual Behavior

schema[role-arg-spec]): Additional properties are not allowed ('aliases' was unexpected)

@nicolasbouchard-ubi nicolasbouchard-ubi added bug new Triage required labels Aug 11, 2023
@ssbarnea
Copy link
Member

@tima @cidrblock As core team keeps making changes to argument_spec, the JSON Schema for validating argument_spec from within linter is always getting out of sync.

Can we please have a talk and look into transitioning this to the same team that develops the argument_spec or at least find some way to prevent surprises via CI testing on core side?

Otherwise we will always be behind when it comes to the schema, having a sub-par implementation of the supported features.

There are multiple ways we can achieve this, some of them could even be very easy to implement. For example, adding running ansible-lint on on argspec fixtures used by core (good or bad) would basically ensure that no new feature is added that is not first included into the JSON Spec.

Also validating a JSON file with a schema can be done in 4-5 lines of python, so even moving the entire schema to core would not be hard, especially as this would not require any user facing changes (only affect the core internal testing).

@ssbarnea ssbarnea self-assigned this Aug 23, 2023
@ssbarnea

This comment was marked as outdated.

@ssbarnea
Copy link
Member

@nicolasbouchard-ubi Please check ansible/ansible#79657 which is an open PR that is expected to make core warn about unknown fields.

Aliases are not supported for role arg-spec, they are only supported for module arg-spec like LOTS of other fields.

Basically the linter does the right thing here. I am not sure how we can improve the experience because too often people that google for argspec endup finding the page about modules instead of roles.

https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html#role-argument-validation

@ssbarnea ssbarnea removed the new Triage required label Aug 23, 2023
@cidrblock
Copy link
Contributor

let me see what I can do.... no promises :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants