Use Fail module.
- Use ignore_errors with every task that you need to ignore in case of errors.
- Set a flag (say, result = false) whenever there is a failure in any task execution
- At the end of the playbook, check if flag is set, and depending on that, fail the execution
- fail: msg="The execution has failed because of errors." when: flag == "failed"
Update:
Use register to store the result of a task like you have shown in your example. Then, use a task like this:
- name: Set flag
set_fact: flag = failed
when: "'FAILED' in command_result.stderr"