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-handler shouldn't trigger on handlers in handlers directory #3767

Closed
ajakk opened this issue Sep 24, 2023 · 2 comments · Fixed by #3838
Closed

no-handler shouldn't trigger on handlers in handlers directory #3767

ajakk opened this issue Sep 24, 2023 · 2 comments · Fixed by #3838
Labels

Comments

@ajakk
Copy link

ajakk commented Sep 24, 2023

Summary

#3655 was incompletely fixed: no-handler still triggers on handlers specified in a separate handler directory.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 6.20.1.dev4 using ansible-core:2.15.3 ansible-compat:4.1.10 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7
You are using a pre-release version of ansible-lint.

Installed from e6bc4c7.

  • ansible installation method: Gentoo package
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
$ grep -r ""
roles/foo/tasks/main.yml:---
roles/foo/tasks/main.yml:- name: Get info
roles/foo/tasks/main.yml:  delegate_to: localhost
roles/foo/tasks/main.yml:  register: collected_info
roles/foo/tasks/main.yml:  ansible.builtin.debug:
roles/foo/tasks/main.yml:    msg: foo
roles/foo/tasks/main.yml:
roles/foo/tasks/main.yml:- name: Do something
roles/foo/tasks/main.yml:  delegate_to: localhost
roles/foo/tasks/main.yml:  loop: "{{ collected_info['some_list'] }}"
roles/foo/tasks/main.yml:  loop_control:
roles/foo/tasks/main.yml:    label: "{{ item.name }}"
roles/foo/tasks/main.yml:  notify:
roles/foo/tasks/main.yml:    - Debug
roles/foo/tasks/main.yml:  register: _something_done
roles/foo/tasks/main.yml:  ansible.builtin.debug:
roles/foo/tasks/main.yml:    msg: foo
roles/foo/handlers/main.yml:---
roles/foo/handlers/main.yml:- name: Debug
roles/foo/handlers/main.yml:  loop: "{{ _something_done.results }}"
roles/foo/handlers/main.yml:  loop_control:
roles/foo/handlers/main.yml:    label: "{{ item.item.name }}"
roles/foo/handlers/main.yml:  when: item.changed
roles/foo/handlers/main.yml:  ansible.builtin.debug:
roles/foo/handlers/main.yml:    msg: "{{ item.item.name }} changed"
$ ansible-lint
WARNING  Listing 1 violation(s) that are fatal
no-handler: Tasks that run when changed should likely be handlers.
roles/foo/handlers/main.yml:2 Task/Handler: Debug

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

            Rule Violation Summary
 count tag        profile rule associated tags
     1 no-handler shared  idiom

Failed: 1 failure(s), 0 warning(s) on 3 files. Last profile that met the validation criteria was 'safety'. Rating: 3/5 star
You are using a pre-release version of ansible-lint.
Desired Behavior

no-handler shouldn't trigger on a handler.

Actual Behavior

no-handler triggers on a handler

$ ansible-lint
WARNING  Listing 1 violation(s) that are fatal
no-handler: Tasks that run when changed should likely be handlers.
roles/foo/handlers/main.yml:2 Task/Handler: Debug

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

            Rule Violation Summary
 count tag        profile rule associated tags
     1 no-handler shared  idiom

Failed: 1 failure(s), 0 warning(s) on 3 files. Last profile that met the validation criteria was 'safety'. Rating: 3/5 star
You are using a pre-release version of ansible-lint.
@ajakk ajakk added bug new Triage required labels Sep 24, 2023
@ajakk ajakk changed the title no-handler shouldn't trigger on handlers in handler directories no-handler shouldn't trigger on handlers in handlers directory Sep 24, 2023
@ssbarnea ssbarnea removed the new Triage required label Sep 27, 2023
@ssbarnea
Copy link
Member

Please create a repository with minimal example for reproducing the bug, otherwise we will close it as not being able to reproduce it. I tried to reproduce it but I was not able to get it to complain about no-handler.

@ajakk
Copy link
Author

ajakk commented Sep 30, 2023

Sure, copied the tasks/handlers from the original issue into https://github.com/ajakk/ansible-lint-3767:

(venv) $ git log -1
commit a1a2380150317e3ca6e0786de51573f5299ce454 (HEAD -> main, origin/main)
Author: John Helmert III <[email protected]>
Date:   Sat Sep 30 13:05:46 2023 -0700

    first commit

    Signed-off-by: John Helmert III <[email protected]>
(venv) $ ansible-lint
WARNING  Unable to load module ansible.builtin.msg at foo/handlers/main.yml:2 for options validation
WARNING  Unable to resolve FQCN for module ansible.builtin.msg
WARNING  Unable to load module somemodule.that.collects.info at foo/tasks/main.yml:2 for options validation
WARNING  Unable to load module somemodule.that.may.change.something at foo/tasks/main.yml:7 for options validation
WARNING  Unable to resolve FQCN for module somemodule.that.collects.info
WARNING  Unable to resolve FQCN for module somemodule.that.may.change.something
WARNING  Listing 1 violation(s) that are fatal
no-handler: Tasks that run when changed should likely be handlers.
foo/handlers/main.yml:2 Task/Handler: Debug

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

            Rule Violation Summary
 count tag        profile rule associated tags
     1 no-handler shared  idiom

Failed: 1 failure(s), 0 warning(s) on 2 files. Last profile that met the validation criteria was 'safety'. Rating: 3/5 star
(venv) $ ansible-lint --version
ansible-lint 6.20.2 using ansible-core:2.15.3 ansible-compat:4.1.10 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7

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.

2 participants