Open
Description
Summary
When placing a text with !unsafe
anchor, this should be ignored by jinja
and not raise any warnings.
For more details see reproducer
Issue Type
- Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 25.6.0 using ansible-core:2.16.14 ansible-compat:25.6.0 ruamel-yaml:0.18.14 ruamel-yaml-clib:0.2.12
STEPS TO REPRODUCE
- Use following playbook as
playbook.yaml
:
- name: Test
hosts:
- localhost
tasks:
- name: Debug task
ansible.builtin.debug:
msg: !unsafe "{{ $testvar }}"
- Execute
ansible-lint playbook.yaml
Desired Behavior
No jinja[invalid]
violation, as the !unsafe text is not templated
Actual Behavior
I'm getting the following output:
playbook.yml:7 unexpected char '$' at 3
Read documentation for instructions on how to ignore specific rule violations.
# Rule Violation Summary
1 jinja profile:basic tags:formatting
Failed: 1 failure(s), 0 warning(s) on 1 files. Last profile that met the validation criteria was 'min'.
Additional context
In the actual example I was encountering, the !unsafe
anchor was in an inventory var file and seemed to be a regression between 25.1.3
and 25.2.0
. With the minimal reproducer, the behavior is also present with 25.1.3
. As I think it's a bug either way (with the same root cause), it's probably not worth making a bigger reproducer where !unsafe
is handled differently between these versions. Let me know if you are interested in another reproducer that aligns closer to this.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status