Skip to content

Commit

Permalink
Fix exception related to include_tasks
Browse files Browse the repository at this point in the history
Fixes: #2875
  • Loading branch information
ssbarnea committed Feb 2, 2023
1 parent 3d86805 commit 0e121fc
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
WSLENV: FORCE_COLOR:PYTEST_REQPASS:TOXENV:GITHUB_STEP_SUMMARY
# Number of expected test passes, safety measure for accidental skip of
# tests. Update value if you add/remove tests.
PYTEST_REQPASS: 774
PYTEST_REQPASS: 775

steps:
- name: Activate WSL1
Expand Down
1 change: 0 additions & 1 deletion a.ansi

This file was deleted.

8 changes: 8 additions & 0 deletions examples/playbooks/tasks/bug-2875.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- name: "Reproduce bug #2875"
include_tasks: "{{ lookup('first_found', __ff_params) }}"
vars:
__ff_params:
files:
- "default.yml"
paths:
- "{{ role_path }}/tasks/setup"
2 changes: 1 addition & 1 deletion src/ansiblelint/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _include_children(
v = v["file"]

# we cannot really parse any jinja2 in includes, so we ignore them
if "{{" in v: # pragma: no branch
if not v or "{{" in v:
return []

if "import_playbook" in k and COLLECTION_PLAY_RE.match(v):
Expand Down
9 changes: 9 additions & 0 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ansiblelint.cli import get_rules_dirs
from ansiblelint.constants import VIOLATIONS_FOUND_RC
from ansiblelint.file_utils import Lintable
from ansiblelint.runner import Runner

runtime = Runtime(require_module=True)

Expand Down Expand Up @@ -390,3 +391,11 @@ def test_nested_items() -> None:
def test_find_children() -> None:
"""Verify correct function of find_children()."""
utils.find_children(Lintable("examples/playbooks/find_children.yml"))


def test_find_children_in_task(default_rules_collection) -> None:
"""Verify correct function of find_children() in tasks."""
Runner(
Lintable("examples/playbooks/tasks/bug-2875.yml"),
rules=default_rules_collection,
).run()

0 comments on commit 0e121fc

Please sign in to comment.