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

Ansible-Lint uppercases handler names but ignores the notifications #4028

Closed
heuwerk opened this issue Feb 15, 2024 · 0 comments · Fixed by #4038
Closed

Ansible-Lint uppercases handler names but ignores the notifications #4028

heuwerk opened this issue Feb 15, 2024 · 0 comments · Fixed by #4038
Assignees
Labels

Comments

@heuwerk
Copy link

heuwerk commented Feb 15, 2024

Summary

when running ansible-lint --fix the names of the handler tasks are correctly renamed to begin with upper case letter.
The Problem is that the notify: my handler remains unchanged, so the next run of the Playbook will fail.

Issue Type
  • Bug Report
OS / ENVIRONMENT
ansible-lint --version
ansible-lint 24.2.0 using ansible-core:2.15.3 ansible-compat:4.1.11 ruamel-yaml:0.18.5 ruamel-yaml-clib:0.2.8
  • ansible installation method: OS package
  • ansible-lint installation method: pip
STEPS TO REPRODUCE
  1. Create a playbook, that calls a handler but the name and notify of the handler is lowercase (see example playbook below)
  2. Run ansible-lint --fix on the playbook
  3. Run ansible-playbook playbook.yaml and it fails
---
- name: Test Playbook
  hosts: localhost
  tasks:
    - name: Task that always changes
      ansible.builtin.debug:
        msg: "I always change!"
      changed_when: true
      notify: my handler

  handlers:
    - name: my handler
      ansible.builtin.debug:
        msg: "I never run :("
Desired Behavior

ansible-lint should uppercase the handler name and the notify call, so the playbook keeps working after running ansible-lint --fix

Possible security bugs should be reported via email to security@ansible.com

Actual Behavior

ERROR: The requested handler 'my handler' was not found in either the main handlers list nor in the listening handlers list

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
---
- name: Test Playbook
  hosts: localhost
  tasks:
    - name: Task that always changes
      ansible.builtin.debug:
        msg: "I always change!"
      changed_when: true
      notify: my handler

  handlers:
# Handler after ansible-lint --fix run
    - name: My handler
      ansible.builtin.debug:
        msg: "I never run :("

$ ansible-playbook playbook.yaml
PLAY [Test Playbook]

TASK [Gathering Facts]
ok: [localhost]

TASK [Task that always changes]*******************
ERROR: The requested handler 'my handler' was not found in either the main handlers list nor in the listening handlers list
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