Introduction Ansible handlers are special tasks that only run when notified by other tasks. When handlers do not trigger as expected, services may not restart after configuration changes, leaving systems in inconsistent states.

Symptoms - Configuration changes applied but service not restarted - Handler listed in playbook output but shows "skipping" - "ERROR! The requested handler was not found" - Handlers run in unexpected order - Handlers not running after failed tasks

Common Causes - Handler name mismatch between notify and handler definition - Handler defined in wrong file or not included - Task does not report "changed" status (handler only runs on change) - Playbook fails before handler execution - Multiple handlers with same name (only first one runs)

Step-by-Step Fix 1. **Verify handler names match notify exactly**: ```yaml # Task - name: Update config copy: src: nginx.conf dest: /etc/nginx/nginx.conf notify: Restart Nginx

# Handler (name must match exactly) - name: Restart Nginx service: name: nginx state: restarted ```

  1. 1.Force handlers to run even on playbook failure:
  2. 2.```bash
  3. 3.ansible-playbook site.yml --force-handlers
  4. 4.`
  5. 5.Listen for multiple events with same handler:
  6. 6.```yaml
  7. 7.handlers:
  8. 8.- name: Restart services
  9. 9.listen: "restart web"
  10. 10.service:
  11. 11.name: "{{ item }}"
  12. 12.state: restarted
  13. 13.loop: [nginx, php-fpm]
  14. 14.`

Prevention - Use consistent handler naming conventions - Test handler execution with --check --diff - Document handler dependencies - Use meta: flush_handlers to force handler execution at specific points - Use ansible-lint to catch handler name mismatches