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

var-naming[no-role-prefix] false positive on cacheable property of ansible.builtin.set_fact #3483

Closed
infracaninophile opened this issue May 23, 2023 · 0 comments · Fixed by #3490
Assignees
Labels

Comments

@infracaninophile
Copy link

Summary

ansible.builin.set_fact can take a cacheable property to control longer term retention on facts. ansible-lint doesn't
distinguish this from the name of a fact to be created, and this triggers the var-naming[no-role-prefix] violation improperly.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.16.2 using ansible-core:2.14.3 ruamel-yaml:0.17.26 ruamel-yaml-clib:0.2.7
  • ansible installation method: OS package -- FreeBSD ports
  • ansible-lint installation method: OS package -- FreeBSD ports
STEPS TO REPRODUCE

Use ansible.builtin.set_fact with cacheable in a role.

Playbook: foo.yaml

---
- name: Illustrate ansible-lint false positive with set_fact and cacheable
  hosts: localhost
  roles:
    - foo_role

Role foo_role/tasks/main.yaml

---

- name: Using set_fact with cacheable
  ansible.builtin.set_fact:
    foo_role_fact: bar
    cacheable: true
Desired Behavior

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

Actual Behavior

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
% ansible-lint foo.yml
WARNING  Listing 1 violation(s) that are fatal
var-naming[no-role-prefix]: Variables names from within roles should use role_name_ as a prefix. (set_fact: cacheable)
roles/foo_role/tasks/main.yaml:5 Task/Handler: Using set_fact with cacheable

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

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

Failed after min profile: 1 failure(s), 0 warning(s) on 2 files.
  • if you're getting a stack trace, also the output of
    ansible-playbook --syntax-check playbook
% ansible-playbook --syntax-check foo.yml

playbook: foo.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants