Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-role-prefix picks up incorrect path component when ANSIBLE_ROLES_PATH is set #3912

Open
ilikejam opened this issue Nov 27, 2023 · 0 comments · May be fixed by #4176
Open

no-role-prefix picks up incorrect path component when ANSIBLE_ROLES_PATH is set #3912

ilikejam opened this issue Nov 27, 2023 · 0 comments · May be fixed by #4176
Labels

Comments

@ilikejam
Copy link

Summary

With ANSIBLE_ROLES_PATH set to e.g.:
ANSIBLE_ROLES_PATH=roles/services:roles/base:roles/contrib

no-role-prefix appears to be picking up the directory before the module as the module name when linting yml in the 'defaults' dir. e.g.:
var-naming[no-role-prefix]: Variables names from within roles should use services_ as a prefix. (vars: proxy_env)
roles/services/signiant_agent/defaults/main.yml:15

This only seems to happen when linting defaults files - yaml under vars is OK.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.22.0 using ansible-core:2.16.0 ansible-compat:4.1.10 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
  • ansible installation method: one of source, pip, OS package
  • ansible-lint installation method: one of source, pip, OS package

Both pip installed on bookworm-slim docker base image

STEPS TO REPRODUCE

Set ANSIBLE_ROLES_PATH=roles/services
Run ansible-lint on a module under roles/services, e.g. roles/services/mything
Observe that 'services_' is the suggested prefix for variables in defaults/main.yml

Desired Behavior

no-role-prefix should suggest variable names based on the module name, rather than its parent directory

Possible security bugs should be reported via email to [email protected]

Actual Behavior

no-role-prefix detects the directory above the module as the module name

Please give some details of what is happening.
Include a minimum complete verifiable example with:

  • minimized playbook to reproduce the error
  • the output of running ansible-lint including the command line used
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook

With the following in roles/services/signiant_agent/defaults/main.yml:

---
signiant_agent_sha: ebc46b2803dcfea61bfe9352e7787acad6b43ed4d7f429e90f8b49af
signiant_agent_install: true

ansible-lint fails with:

var-naming[no-role-prefix]: Variables names from within roles should use services_ as a prefix. (vars: signiant_agent_sha)
roles/services/signiant_agent/defaults/main.yml:2

var-naming[no-role-prefix]: Variables names from within roles should use services_ as a prefix. (vars: signiant_agent_install)
roles/services/signiant_agent/defaults/main.yml:3
@ilikejam ilikejam added bug new Triage required labels Nov 27, 2023
@shatakshiiii shatakshiiii removed the new Triage required label Nov 29, 2023
cavcrosby added a commit to cavcrosby/ansible-lint that referenced this issue May 19, 2024
@cavcrosby cavcrosby linked a pull request May 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Roadmap
Development

Successfully merging a pull request may close this issue.

2 participants