Skip to content

Commit

Permalink
name[template]: only trigger on word characters after the template (#…
Browse files Browse the repository at this point in the history
…2836)

This allows tasks being called like

    Do the thing with '{{ template }}'

Which makes the task name better readable if `template` contains spaces
  • Loading branch information
evgeni committed Dec 31, 2022
1 parent b7fb66a commit 7c9a970
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions examples/playbooks/rule-name-templated-fail.yml
Expand Up @@ -8,3 +8,6 @@
- name: This task is correctly templated {{ sampleService }}
ansible.builtin.command: echo "Hello World"
changed_when: false
- name: This task is correctly templated '{{ sampleService }}'
ansible.builtin.command: echo "Hello World"
changed_when: false
2 changes: 1 addition & 1 deletion src/ansiblelint/rules/name.py
Expand Up @@ -25,7 +25,7 @@ class NameRule(AnsibleLintRule):
severity = "MEDIUM"
tags = ["idiom"]
version_added = "v6.9.1 (last update)"
_re_templated_inside = re.compile(r".*\{\{.*\}\}(.+)$")
_re_templated_inside = re.compile(r".*\{\{.*\}\}.*\w.*$")

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

0 comments on commit 7c9a970

Please sign in to comment.