Skip to content

Commit

Permalink
Avoid jinja[invalid] with vars on task (#2588)
Browse files Browse the repository at this point in the history
Fixes: #2569
  • Loading branch information
ssbarnea authored Oct 10, 2022
1 parent 30f6b26 commit 0e672f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions examples/playbooks/rule-jinja-valid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@
owner: "root"
group: "dovecot"
mode: "0640"
- name: Bug https://github.com/ansible/ansible-lint/issues/2569
ansible.builtin.include_tasks:
file: /dev/null
vars:
ns_vars: {}
x: "{{ lookup('ansible.builtin.template', 'namespace.yaml.j2', template_vars=ns_vars) | from_yaml }}"
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/jinja.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def matchtask( # noqa: C901
template(
basedir=file.dir if file else ".",
value=v,
variables={},
variables=task.get("vars", {}),
fail_on_error=True, # we later decide which ones to ignore or not
)
# ValueError RepresenterError
Expand Down

0 comments on commit 0e672f0

Please sign in to comment.