# Ansible-lint name\[template\] with multiple vars

**URL:** <https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530>\
**Category:** Get Help\
**Tags:** jinja2, ansible-lint\
**Created:** [September 16, 2024, 9:27am UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530 "2024-09-16T09:27:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [September 16, 2024, 9:27am UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/1 "2024-09-16T09:27:18Z")

</div>

Hello,

I ask an help to avoid this error:

```auto
name[template]: Jinja templates should only be at the end of 'name'
roles/role_name/tasks/main.yml:39 Task/Handler: Copy file in {{ role_name_conf.dest }} of {{ role_name_server.name }}

```

Does this rule implicitly says that only a single one var can be added in the task name?

Is there a way to add mutiple vars without trigger this violation?

Of course, I can add a lint skip, but I would like to write plays without skipping rules.

Thank you very much for every hints.

```auto
# ansible-lint --version
ansible-lint 24.7.0 using ansible-core:2.16.9 ansible-compat:24.7.0 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8

```

Kind Regards  
Marco

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [September 16, 2024, 10:00am UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/2 "2024-09-16T10:00:10Z")

</div>

You can work around this in a way that also results in the `name` being templated when it wouldn’t otherwise be (for example when a task is skipped?), for example:

```yaml
- name: "{{ task_name }}"
  ansible.foo.bar:
  vars:
    task_name: "{{ foo }} {{ bar }}"

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 16, 2024, 12:39pm UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/3 "2024-09-16T12:39:55Z")

</div>

Or simply use a `noqa` to disable this rule locally, or even disable it globally if you disagree with this rule.

---

<div class="post-metadata">

**Author:** ![falon](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/falon/32/2081_2.png) [@falon](https://forum.ansible.com/u/falon)\
**Post date:** [September 16, 2024, 12:47pm UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/4 "2024-09-16T12:47:42Z")

</div>

The two above answers are very good solutions for me.  
I forgot the **# noqa** , which is very easy for these locally workarounds.

Thank you very much @chris and @felixfontein 🔝

Marco

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [September 16, 2024, 6:13pm UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/5 "2024-09-16T18:13:38Z")

</div>

Yet another solution

```auto
Copy file in {{ role_name_conf.dest ~ ' of ' ~ role_name_server.name }}

```

or

```auto
Copy file in {{ ' of '.join( [role_name_conf.dest, role_name_server.name]) }}

```

---

<div class="post-metadata">

**Author:** ![felixfontein](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/felixfontein/32/7530_2.png) [@felixfontein](https://forum.ansible.com/u/felixfontein)\
**Post date:** [September 16, 2024, 6:35pm UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/6 "2024-09-16T18:35:17Z")

</div>

The rationale behind that rule is to simplify finding the task in the playbook based on the task’s name. All workarounds make it harder to find the corresponding task, or make it harder to read the template code.

So either rewrite the task’s title (and not the way you template it) so you only need to template in one place (namely at the end), or use `noqa` / disable the rule. Every other solution makes the situation worse and goes against the spirit of the linting rule.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [October 16, 2024, 6:36pm UTC](https://forum.ansible.com/t/ansible-lint-name-template-with-multiple-vars/8530/7 "2024-10-16T18:36:08Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
