diff --git a/src/ansiblelint/constants.py b/src/ansiblelint/constants.py index cfb8289b5a..43117160a8 100644 --- a/src/ansiblelint/constants.py +++ b/src/ansiblelint/constants.py @@ -61,11 +61,9 @@ def main(): FileType = Literal[ "playbook", - "pre_tasks", - "post_tasks", "meta", # role meta - "tasks", - "handlers", + "tasks", # includes pre_tasks, post_tasks + "handlers", # very similar to tasks but with some specificts # https://docs.ansible.com/ansible/latest/galaxy/user_guide.html#installing-roles-and-collections-from-the-same-requirements-yml-file "requirements", "role", # that is a folder! diff --git a/src/ansiblelint/skip_utils.py b/src/ansiblelint/skip_utils.py index b0fe2a5b12..030e3e77ea 100644 --- a/src/ansiblelint/skip_utils.py +++ b/src/ansiblelint/skip_utils.py @@ -99,7 +99,7 @@ def _append_skipped_rules(pyyaml_data: Sequence[Any], lintable: Lintable) -> Seq if lintable.kind in ('tasks', 'handlers'): ruamel_task_blocks = ruamel_data pyyaml_task_blocks = pyyaml_data - elif lintable.kind in ('playbook', 'pre_tasks', 'post_tasks'): + elif lintable.kind == 'playbook': try: pyyaml_task_blocks = _get_task_blocks_from_playbook(pyyaml_data) ruamel_task_blocks = _get_task_blocks_from_playbook(ruamel_data) diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index e82922e97e..0e34ba798b 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -468,15 +468,14 @@ def _look_for_role_files(basedir: str, role: str, main='main') -> List[Lintable] results = [] - for kind in ['tasks', 'meta', 'handlers']: + for kind in ['tasks', 'meta', 'handlers', 'vars', 'defaults']: current_path = os.path.join(role_path, kind) for folder, subdirs, files in os.walk(current_path): for file in files: file_ignorecase = file.lower() if file_ignorecase.endswith(('.yml', '.yaml')): thpath = os.path.join(folder, file) - # TODO(ssbarnea): Find correct way to pass kind: FileType - results.append(Lintable(thpath, kind=kind)) # type: ignore + results.append(Lintable(thpath)) return results