Skip to content

jinja spacing warning on windows line-endings #4681

@myllynen

Description

@myllynen
Summary

ansible-lint gives a jinja[spacing] warning for variables with Windows line-endings.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 25.6.1 using ansible-core:2.19.0rc2 ansible-compat:25.6.0 ruamel-yaml:0.18.14 ruamel-yaml-clib:0.2.12
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
$ cat roles/test/defaults/main.yml
---
init_msg: "Created on {{ '%Y-%m-%d %H:%M:%S %Z' | strftime }}.\r\n"
...
$ ansible-lint roles/test/defaults/main.yml
...
jinja[spacing]: Jinja2 spacing could be improved: Created on {{ '%Y-%m-%d %H:%M:%S %Z' | strftime }}.
 -> Created on {{ '%Y-%m-%d %H:%M:%S %Z' | strftime }}.
 (warning)
roles/test/defaults/main.yml:2:11 Jinja2 template rewrite recommendation: `Created on {{ '%Y-%m-%d %H:%M:%S %Z' | strftime }}.
`.
...
Desired Behavior

No warnings when using Windows line-endings.

Actual Behavior

See above. Removing \r from the string avoids the warning but then the line isn't using the standard Windows line-ending. Switching quotes so that single-quotes are the outer quotes would result using literal \r\n.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Roadmap

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions