Skip to content

Support for argument_specs #1966

@tumbl3w33d

Description

@tumbl3w33d
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

Metadata

Metadata

Assignees

Labels

AAPAnsible Automation Platform

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions