Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update var-naming to allow names containing jinja2 templates #1988

Merged
merged 1 commit into from
Mar 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/ansiblelint/rules/var_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
CamelCase: ...
ALL_CAPS: ...
ALL_CAPS_ARE_BAD_TOO: ... # invalid

tasks:
- name: foo
ansible.builtin.set_fact:
"{{ 'test_' }}var": "value" # valid
"""


Expand Down Expand Up @@ -58,6 +63,10 @@ def is_invalid_variable_name(self, ident: str) -> bool:
if keyword.iskeyword(ident):
return False

# We want to allow use of jinja2 templating for variable names
if "{{" in ident:
return False

# previous tests should not be triggered as they would have raised a
# syntax-error when we loaded the files but we keep them here as a
# safety measure.
Expand Down