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

ansible-lint needs a recursive discovery mode #613

Closed
ssbarnea opened this issue Nov 1, 2019 · 0 comments · Fixed by #615
Closed

ansible-lint needs a recursive discovery mode #613

ssbarnea opened this issue Nov 1, 2019 · 0 comments · Fixed by #615
Labels

Comments

@ssbarnea
Copy link
Member

ssbarnea commented Nov 1, 2019

Issue Type

  • Feature request

Desired Behaviour

Currently ansible-lint cannot safely used like other linters which are able to look recursively inside the repository and lint whatever they find. Attempt to run ansible-lint . would result into a false-positive result, likely linting nothing if not playbook is present.

Once complex repository example can be seen at https://github.com/rdo-infra/ci-config/ as this exposes several important aspects:

  • not all yaml files are Ansible related
  • roles can be stored in multiple subdirectories: ci-scripts/container-push/roles,... and several others.
  • playbooks can also be scattered around in multiple locations
  • using exclude_paths can help but does not fix the inclusion part
  • finding all .yaml files and passing them to ansible-lint (like pre-commit does by default) would confuse it because it may not be able to identify the nature of these files and may end-up trying to parse tasks or vars as playbooks.
  • playbooks could be found inside roledir/molecule/*.yml with one notable exception: molecule.yml which is clearly not a playbook. I am not sure if we could just assume that the other files are playbooks or not.

While I do not mind making the assumption that roles are to found in folders with roles in their name, there is one signifiant exception: single-role repositories.

Before doing any work on this, we may need some help from Ansible team regarding on what information can and should be used to determine what is an Ansible playbook or role.

Desired outcome

If sorted correctly, newly added playbooks and roles should be linted without having to reconfigure the ansible-linter.

The user should be able to run ansible-lint without any arguments to lint the entire repository, just like flake8 and others are working.

webknjaz pushed a commit that referenced this issue Nov 4, 2019
When called without any arguments, ansible-lint will now try to look
for all playbooks and roles inside current git repository.

Unrecognized YAML files will be displayed in verbose mode but will not
be considered errors. This will allow users to enable ansible-lint
on any repository without being forced to alter the way is called or
its configuration each time a new playbooks/role is added.

Fixes: #613
Fixes: #564
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
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.

2 participants