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

Support for argument_specs #1966

Closed
tumbl3w33d opened this issue Mar 9, 2022 · 1 comment · Fixed by #2131
Closed

Support for argument_specs #1966

tumbl3w33d opened this issue Mar 9, 2022 · 1 comment · Fixed by #2131
Assignees
Labels
AAP Ansible Automation Platform enhancement

Comments

@tumbl3w33d
Copy link

Summary

The ansible documentation states:

Beginning with version 2.11, you may choose to enable role argument validation based on an argument specification. This specification is defined in the meta/argument_specs.yml file […]

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

Issue Type
  • Bug Report
Ansible and Ansible Lint details
ansible [core 2.12.3]
  config file = /home/myuser/myproject/ansible.cfg
  configured module search path = ['/home/myuser/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/myuser/myproject/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /home/myuser/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/myuser/myproject/venv/bin/ansible
  python version = 3.10.2 (main, Jan 15 2022, 19:56:27) [GCC 11.1.0]
  jinja version = 3.0.3
  libyaml = True

ansible-lint 5.4.0 using ansible 2.12.3
  • ansible installation method: pip
  • ansible-lint installation method: pip
OS / ENVIRONMENT

Linux 5.15.25-1-MANJARO #1 SMP PREEMPT Wed Feb 23 14:44:03 UTC 2022

STEPS TO REPRODUCE
  • create a role with a meta folder
  • create a argument_specs.yml in it
  • fill it with a argument_specs block, as the documentation shows
argument_specs:
  main:
    short_description: does stuff
Desired Behavior

Ansible lint should either handle this file in an appropriate way or at least ignore it.

Actual Behavior

Result is a syntax-check violation:

$ ansible-lint myrole/meta/argument_specs.yml 
WARNING  Overriding detected file kind 'yaml' with 'playbook' for given positional argument: myrole/meta/argument_specs.yml
WARNING  Listing 1 violation(s) that are fatal
syntax-check: A playbook must be a list of plays, got a <class 'ansible.parsing.yaml.objects.AnsibleMapping'> instead
myrole/meta/argument_specs.yml:2:1
ERROR! A playbook must be a list of plays, got a <class 'ansible.parsing.yaml.objects.AnsibleMapping'> instead
The offending line appears to be:
[…]
---
argument_specs:
^ here
@tumbl3w33d tumbl3w33d added bug new Triage required labels Mar 9, 2022
@ssbarnea ssbarnea removed the new Triage required label Mar 18, 2022
@ssbarnea ssbarnea self-assigned this Mar 18, 2022
@ssbarnea ssbarnea added new Triage required enhancement and removed bug labels Mar 18, 2022
@ssbarnea
Copy link
Member

This is not a bug as you did not read well the documentation of arguments. Any given filename is assumed to be a playbook, overriding the file type detection. The linter does not give any errors when you allow it to detect the files (no arguments).

Still, validating thew argument_specs is clearly something we want to add to it.

@ssbarnea ssbarnea changed the title argument_specs cause syntax-check violation Support for argument_specs Mar 18, 2022
@ganeshrn ganeshrn added AAP Ansible Automation Platform and removed new Triage required labels Mar 23, 2022
ziegenberg added a commit to ziegenberg/ansible-lint that referenced this issue May 1, 2022
…based on argument specification

Beginning with ansible version 2.11 role argument validation based on an
argument specification was introduced. This specification is defined in
the meta/argument_specs.yml file of a role.

This change enables the linter to detect this new format and for it to
be used in future rules.

Fixes: ansible#1688
Relates: ansible#1966

Signed-off-by: Daniel Ziegenberg <[email protected]>
ziegenberg added a commit to ziegenberg/ansible-lint that referenced this issue May 1, 2022
…based on argument specification

Beginning with ansible version 2.11 role argument validation based on an
argument specification was introduced. This specification is defined in
the meta/argument_specs.yml file of a role.

This change enables the linter to detect this new format and for it to
be used in future rules.

Fixes: ansible#1688
Relates: ansible#1966

Signed-off-by: Daniel Ziegenberg <[email protected]>
ssbarnea pushed a commit that referenced this issue May 3, 2022
Beginning with ansible version 2.11 role argument validation based on an
argument specification was introduced. This specification is defined in
the meta/argument_specs.yml file of a role.

This change enables the linter to detect this new format and for it to
be used in future rules.

Fixes: #1688
Relates: #1966

Signed-off-by: Daniel Ziegenberg <[email protected]>
ssbarnea added a commit to ssbarnea/schemas that referenced this issue May 13, 2022
ssbarnea added a commit to ansible/schemas that referenced this issue May 13, 2022
ssbarnea added a commit to ssbarnea/ansible-lint that referenced this issue May 13, 2022
Repository owner moved this from Todo to Done (AAP 2.2) in 🧰 devtools project board May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AAP Ansible Automation Platform enhancement
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants