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

Linting result of include_role with wrong syntax is suppressed #4007

Closed
iay opened this issue Feb 4, 2024 · 0 comments · Fixed by #4026
Closed

Linting result of include_role with wrong syntax is suppressed #4007

iay opened this issue Feb 4, 2024 · 0 comments · Fixed by #4026
Assignees
Labels

Comments

@iay
Copy link

iay commented Feb 4, 2024

Summary

If you use ansible.builtin.include_role and use role rather than name as the name of the role to include, ansible-lint suppresses output.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint 6.22.2 using ansible-core:2.16.3 ansible-compat:4.1.11 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8

macOS Sonoma, Intel Mac.

  • ansible installation method: pip
  • ansible-lint installation method: pip
STEPS TO REPRODUCE

Correct syntax for include_task gives expected result (intentionally unnamed task is flagged):

---
- name: Demonstrate linting issue.
  hosts: all
  tasks:
    - name: Include a role with the correct syntax
      ansible.builtin.include_role:
        name: foo

    - ansible.builtin.setup:
ansible-lint test.yml
WARNING  Skipped installing old role dependencies due to running in offline mode.
WARNING  Skipped installing collection dependencies due to running in offline mode.
WARNING  Listing 1 violation(s) that are fatal
name[missing]: All tasks should be named.
test.yml:9 Task/Handler: setup 

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

              Rule Violation Summary              
 count tag           profile rule associated tags 
     1 name[missing] basic   idiom                

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

Incorrect syntax still works, but linting output is suppressed even for other issues:

---
- name: Demonstrate linting issue.
  hosts: all
  tasks:
    - name: Include a role with the wrong syntax
      ansible.builtin.include_role:
        role: foo

    - ansible.builtin.setup:
ansible-lint test.yml
WARNING  Skipped installing old role dependencies due to running in offline mode.
WARNING  Skipped installing collection dependencies due to running in offline mode.
WARNING  Listing 2 violation(s) that are fatal
WARNING  A rule (load-failure) that is not part of a collection cannot access its configuration.
A rule (load-failure) that is not part of a collection cannot access its configuration.
Desired Behavior

I think it would be reasonable for ansible-lint to say which fatal violation it had detected.

Actual Behavior

There's really no clue here as to what the issue is, and worse Ansible itself actually seems to accept the incorrect syntax. Other things that ansible-lint detects are also suppressed in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants