Skip to content

rules var-naming[no-role-prefix] and var-naming[pattern] collide if var_naming_pattern is changed from default #4142

Open
@mhallin2

Description

@mhallin2
Summary

Role variable prefix does not work if var_naming_pattern: has been altered from its default.
#Bradley Thornton has requested me to create this as a bug.

If the var_naming_pattern setting in .ansible-lint.cfg file is changed from its default
and you create a role and use set_fact to set a variable
The rules var-naming[no-role-prefix] and var-naming[pattern] will collide as both scenarios can not be fulfilled

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 24.2.3 using ansible-core:2.16.6 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE

update .ansible-lint with the below setting

var_naming_pattern: "^[A-Z_][A-Za-z0-9_]*$"

Add a variable to the role vars main.yml file

---
Register_DNS_Host_Record_Variable: dummyvalue

Run ansible-lint on the new role

ansible-lint /collections/mynamespace/network/roles/register_dns_host_record
Desired Behavior

No errors should be reported

Actual Behavior

var-naming[no-role-prefix]: Variables names from within roles should use register_dns_host_record_ as a prefix. (vars: Register_DNS_Host_Record_Variable)

Metadata

Metadata

Assignees

No one assigned

    Labels

    AAPAnsible Automation Platformbug

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions