Skip to content

Commit 7c9a970

Browse files
authored
name[template]: only trigger on word characters after the template (#2836)
This allows tasks being called like Do the thing with '{{ template }}' Which makes the task name better readable if `template` contains spaces
1 parent b7fb66a commit 7c9a970

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

examples/playbooks/rule-name-templated-fail.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@
88
- name: This task is correctly templated {{ sampleService }}
99
ansible.builtin.command: echo "Hello World"
1010
changed_when: false
11+
- name: This task is correctly templated '{{ sampleService }}'
12+
ansible.builtin.command: echo "Hello World"
13+
changed_when: false

src/ansiblelint/rules/name.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class NameRule(AnsibleLintRule):
2525
severity = "MEDIUM"
2626
tags = ["idiom"]
2727
version_added = "v6.9.1 (last update)"
28-
_re_templated_inside = re.compile(r".*\{\{.*\}\}(.+)$")
28+
_re_templated_inside = re.compile(r".*\{\{.*\}\}.*\w.*$")
2929

3030
def matchplay(self, file: Lintable, data: dict[str, Any]) -> list[MatchError]:
3131
"""Return matches found for a specific play (entry in playbook)."""

0 commit comments

Comments
 (0)