Using custom message when a task fails

Hello

I am using ansible version 1.8.2.
I would like to know if its possible to add a custom message when a task fails.
I understand that one way to do is

  • name: Run Shell Command
    shell: ./script.sh
    register: results
    ignore_errors: yes

  • fails: msg=“Command was not executed successfully”
    when: results.rc != 0

But to reduce the lines of code failed_when was introduced.

  • name: Run Shell Command
    shell: ./script.sh
    register: results
    failed_when: “results.rc != 0”

However when using failed_when I loose the option to have a custom message. Is there a way to have custom when using failed_when or better way to implement this.

Howevre I found that from Ansible 2.0 there is concept of Blocks that can be a solution to my problem. But I want to how it can be implemented in version < 2.0

Thanks for your answers
AJ

no, pretty much what you already noted are the only options.