Skip to content

var-naming[pattern] is also applied to vars that are not owned by the linted code #4095

@evgeni

Description

@evgeni
Summary

When linting roles/playbooks that include "foreign" roles and var-naming[pattern] is set, that pattern is also applied to vars passed to those foreign roles

Issue Type
  • Bug Report
OS / ENVIRONMENT
% ansible-lint --version
ansible-lint 24.2.1 using ansible-core:2.16.5 ansible-compat:4.1.11 ruamel-yaml:0.18.6 ruamel-yaml-clib:0.2.8
  • ansible installation method: Fedora RPM (irrelevant)
  • ansible-lint installation method: pip (irrelevant)
STEPS TO REPRODUCE
% cat .ansible-lint 
---
var_naming_pattern: "^(__)?satellite_[a-z_][a-z0-9_]*$"

% cat playbooks/install.yml 
---
- name: Setup
  hosts: localhost
  tasks:
    - name: Setup repositories
      ansible.builtin.include_role:
        name: theforeman.operations.foreman_repositories
      vars:
        foreman_repositories_version: "3.10"

% ansible-lint          
WARNING  Listing 1 violation(s) that are fatal
var-naming[pattern]: Variables names should match ^(__)?satellite_[a-z_][a-z0-9_]*$ regex. (foreman_repositories_version) (vars: foreman_repositories_version)
playbooks/install.yml:9 Task/Handler: Setup repositories

Read documentation for instructions on how to ignore specific rule violations.

                 Rule Violation Summary                 
 count tag                 profile rule associated tags 
     1 var-naming[pattern] basic   idiom                

Failed: 1 failure(s), 0 warning(s) on 2 files. Last profile that met the validation criteria was 'min'.
Desired Behavior

I would expect ansible-lint to catch that this is calling out to foreign code, and not apply var-naming[pattern] here.

Actual Behavior

Please see above "steps to reproduce"

Additional information

I've seen this on 6.18.0 and 24.2.1.
I am certain some older version did not have this issue, but I don't have data which one exactly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions