# Role var/param naming (prefix)

**URL:** <https://forum.ansible.com/t/role-var-param-naming-prefix/1855>\
**Category:** Get Help\
**Tags:** collections, galaxy-ng\
**Created:** [October 22, 2023, 12:19am UTC](https://forum.ansible.com/t/role-var-param-naming-prefix/1855 "2023-10-22T00:19:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![charlesrocket](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/charlesrocket/32/986_2.png) [@charlesrocket](https://forum.ansible.com/u/charlesrocket)\
**Post date:** [October 22, 2023, 12:19am UTC](https://forum.ansible.com/t/role-var-param-naming-prefix/1855/1 "2023-10-22T00:19:16Z")

</div>

I was converting one of my playbooks into a collection to utilize galaxy instead of manual source control for swift deployment when realized that var prefix is not enforced anymore. Since this is now a collection, it makes sense to allow correct usage outside of my playbooks. But I am not sure if I should add prefixes to all role vars (params) or keep current layout Am I getting this right that now variables supplied as parameters to a role would resolve possible collisions since role params would have higher priority?

current state (role example) [charlesrocket.freebsd.desktop role – Deploys desktop tunings — charlesrocket.freebsd Ansible collection documentation](https://charlesrocket.github.io/freebsd-collection/desktop_role.html#ansible-collections-charlesrocket-freebsd-desktop-role)

Back in the days I would append prefix as I did with dotfiles role (in another collection) and linter would agree but things seems to be different now and I can’t find any relative documentation with active links.

current var usage (playbook): [https://github.com/charlesrocket/freebsd-collection/blob/trunk/profiles/charlesrocket/station.yml](https://github.com/charlesrocket/freebsd-collection/blob/trunk/profiles/charlesrocket/station.yml)

I thought the linter would help to clear things out but I can not make it to complain on the topic no matter what I do 😀 - like it does not care anymore about var prefixes.

---

<div class="post-metadata">

**Author:** ![utoddl](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/utoddl/32/249_2.png) [@utoddl](https://forum.ansible.com/u/utoddl)\
**Post date:** [April 6, 2024, 10:14pm UTC](https://forum.ansible.com/t/role-var-param-naming-prefix/1855/2 "2024-04-06T22:14:49Z")

</div>

I’ve [whined about this](http://forum.ansible.com/t/ansible-lint-and-the-role-prefix-on-variable-names-in-collections/2935) but from the other side. That is, I want Fully Qualified Variable Names (FQVN), not just prefixed with the role name. The fact that I have three distinct roles with the same name - one stand-alone and two in collections - makes a role-only prefix not particularly helpful. (It wasn’t my idea! I just implemented 'em, honest!)

`ansible-lint` will complain if you pass un-prefixed variables in a `vars` section of an `include_role` task. But it can’t really complain about a role using variables that aren’t prefixed; it has no way of knowing if those variables are unique to the role or if they come from elsewhere (I’m guessing).

---

<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:** [April 7, 2024, 7:56am UTC](https://forum.ansible.com/t/role-var-param-naming-prefix/1855/3 "2024-04-07T07:56:48Z")

</div>

I think @evgeni also mentioned something like that not too long ago, IIRC on Matrix, for the Foreman collection. There the role names are short and somewhat generic ([foreman-ansible-modules/roles at develop · theforeman/foreman-ansible-modules · GitHub](https://github.com/theforeman/foreman-ansible-modules/tree/develop/roles)) and you don’t want just these as a prefix. In case of the Foreman collection, all var names start with `foreman_` (or `__foreman_` for private vars), so a first solution (instead of using `# noqa`) was to set `var_naming_pattern`: [foreman-ansible-modules/.ansible-lint at develop · theforeman/foreman-ansible-modules · GitHub](https://github.com/theforeman/foreman-ansible-modules/blob/develop/.ansible-lint#L4)

---

<div class="post-metadata">

**Author:** ![evgeni](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/evgeni/32/2686_2.png) [@evgeni](https://forum.ansible.com/u/evgeni)\
**Post date:** [April 8, 2024, 9:28am UTC](https://forum.ansible.com/t/role-var-param-naming-prefix/1855/4 "2024-04-08T09:28:47Z")

</div>

Yeah. Just be aware that `var-naming[pattern]` is not free of issues either:  
[https://github.com/ansible/ansible-lint/issues/4095](https://github.com/ansible/ansible-lint/issues/4095)
