--- - name: Check if kernel or microcode update requires reboot ansible.builtin.script: check_reboot.zsh # Your script placed in files/ register: reboot_check # Prevent Ansible from failing if the script returns false (exit code 1) failed_when: false # Trigger the handler ONLY if the script returns true (exit code 0) changed_when: reboot_check.rc == 0 notify: Reboot system