mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-23 05:10:40 +00:00
Robert Kaussow
43d7edca32
* refactor plugin system to use a class-based approach * disable some docstring linter errors and fix imports * cleanup * fix docs * add metavars to cli arguments for better helptext * add option to disable buildin rules * remove print * remove dead code
28 lines
991 B
Python
28 lines
991 B
Python
from ansiblelater.standard import StandardBase
|
|
|
|
|
|
class CheckNamedTask(StandardBase):
|
|
|
|
sid = "ANSIBLE0006"
|
|
description = "Tasks and handlers must be named"
|
|
helptext = "module '{module}' used without or empty `name` attribute"
|
|
version = "0.1"
|
|
types = ["playbook", "task", "handler"]
|
|
|
|
def check(self, candidate, settings):
|
|
tasks, errors = self.get_normalized_tasks(candidate, settings)
|
|
nameless_tasks = [
|
|
"meta", "debug", "include_role", "import_role", "include_tasks", "import_tasks",
|
|
"include_vars", "block"
|
|
]
|
|
|
|
if not errors:
|
|
for task in tasks:
|
|
module = task["action"]["__ansible_module__"]
|
|
if ("name" not in task or not task["name"]) and module not in nameless_tasks:
|
|
errors.append(
|
|
self.Error(task["__line__"], self.helptext.format(module=module))
|
|
)
|
|
|
|
return self.Result(candidate.path, errors)
|