summaryrefslogtreecommitdiffstats
path: root/test/rules/fixtures/raw_task.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/rules/fixtures/raw_task.py')
-rw-r--r--test/rules/fixtures/raw_task.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/rules/fixtures/raw_task.py b/test/rules/fixtures/raw_task.py
new file mode 100644
index 0000000..672789d
--- /dev/null
+++ b/test/rules/fixtures/raw_task.py
@@ -0,0 +1,25 @@
+"""Test Rule that needs_raw_task."""
+from __future__ import annotations
+
+from typing import Any
+
+from ansiblelint.file_utils import Lintable
+from ansiblelint.rules import AnsibleLintRule
+
+
+class RawTaskRule(AnsibleLintRule):
+ """Test rule that inspects the raw task."""
+
+ id = "raw-task"
+ shortdesc = "Test rule that inspects the raw task"
+ tags = ["fake", "dummy", "test3"]
+ needs_raw_task = True
+
+ def matchtask(
+ self, task: dict[str, Any], file: Lintable | None = None
+ ) -> bool | str:
+ """Match a task using __raw_task__ to inspect the module params type."""
+ raw_task = task["__raw_task__"]
+ module = task["action"]["__ansible_module_original__"]
+ found_raw_task_params = not isinstance(raw_task[module], dict)
+ return found_raw_task_params