Summary
Ansible-lint (starting version 6.17) reports var-naming[no-role-prefix] issue for all role variables that are not starting with <role_name> prefix.
I don't think it's correct. Do we rally want' to prefix every single variable in the role like this. It's not throwing warning for variables created by loops (for example.)
Issue Type
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.17.0 using ansible-core:2.15.0 ruamel-yaml:0.17.21 ruamel-yaml-clib:0.2.7
- ansible installation method: pip
- ansible-lint installation method: pip
STEPS TO REPRODUCE
ansible-lint roles/ playbook.yml
# (code attached)
WARNING Listing 2 violation(s) that are fatal
var-naming[no-role-prefix]: Variables names from within roles should use role_name_ as a prefix. (vars: some_block_internal_var)
roles/lint_test/tasks/main.yml:8 Task/Handler: Block var test
var-naming[no-role-prefix]: Variables names from within roles should use role_name_ as a prefix. (vars: temp_var)
roles/lint_test/tasks/main.yml:20 Task/Handler: Task vars
Read documentation for instructions on how to ignore specific rule violations.
Rule Violation Summary
count tag profile rule associated tags
2 var-naming[no-role-prefix] basic idiom
Desired Behavior
I think that task vars:
- name: Task vars
vars:
temp_var: this_is_temp_var
ansible.builtin.debug:
var: temp_var
or block vars (technically task vars too)
- name: Block var test
# I think ansible-lint should nore report var-naming[no-role-prefix] here
vars:
some_block_internal_var: "block var"
block:
- name: Debug inside block
ansible.builtin.debug:
var: some_block_internal_var
- name: Debug outside the block - inside the role code
ansible.builtin.debug:
var: some_block_internal_var
should not be reported as issues.
Actual Behavior
Getting linter issues for things that should probably be ignored/skipped.
Summary
Ansible-lint (starting version 6.17) reports var-naming[no-role-prefix] issue for all role variables that are not starting with <role_name> prefix.
I don't think it's correct. Do we rally want' to prefix every single variable in the role like this. It's not throwing warning for variables created by loops (for example.)
Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
Desired Behavior
I think that task vars:
or block vars (technically task vars too)
should not be reported as issues.
Actual Behavior
Getting linter issues for things that should probably be ignored/skipped.