Skip to content

Commit

Permalink
src/ansiblelint/utils.py: Ensure that the role file is not a file (#1522
Browse files Browse the repository at this point in the history
)

If a role contains something like a file called roles/.gitkeep,
ansible-lint will classify it as a role while it has no chance
to be a role (since it's a file). Add a check in _extend_with_roles()
to avoid linting files as a role.

Signed-off-by: Arnaud Patard <apatard@hupstream.com>
  • Loading branch information
apatard committed Apr 8, 2021
1 parent e9cf489 commit 30e08e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansiblelint/utils.py
Expand Up @@ -822,7 +822,7 @@ def _extend_with_roles(lintables: List[Lintable]) -> None:
role = lintable.path
while role.parent.name != "roles" and role.name:
role = role.parent
if role.exists:
if role.exists and not role.is_file():
lintable = Lintable(role, kind="role")
if lintable not in lintables:
_logger.debug("Added role: %s", lintable)
Expand Down

0 comments on commit 30e08e4

Please sign in to comment.