Skip to content

Commit 0e672f0

Browse files
authored
Avoid jinja[invalid] with vars on task (#2588)
Fixes: #2569
1 parent 30f6b26 commit 0e672f0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

examples/playbooks/rule-jinja-valid.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@
2020
owner: "root"
2121
group: "dovecot"
2222
mode: "0640"
23+
- name: Bug https://github.com/ansible/ansible-lint/issues/2569
24+
ansible.builtin.include_tasks:
25+
file: /dev/null
26+
vars:
27+
ns_vars: {}
28+
x: "{{ lookup('ansible.builtin.template', 'namespace.yaml.j2', template_vars=ns_vars) | from_yaml }}"

src/ansiblelint/rules/jinja.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def matchtask( # noqa: C901
6262
template(
6363
basedir=file.dir if file else ".",
6464
value=v,
65-
variables={},
65+
variables=task.get("vars", {}),
6666
fail_on_error=True, # we later decide which ones to ignore or not
6767
)
6868
# ValueError RepresenterError

0 commit comments

Comments
 (0)