title: Print custom message from until loop in ansible
body: <p>I am trying to run a command multiple times and check if the output contains some string in it("hi"). I am purposefully simulating failure and expecting the <code>until</code> loop to fail. Everything is good till this point. </p>
  
  <p>Now, I need to have some custom message stating why the <code>until</code> loop or the <code>task</code> failed. For Example: <code>"Your command failed to print hi"</code></p>
  
  <p><strong>So Question is</strong>, How can I print custom message from until loop if the loop failed to pass withing the retries. </p>
  
  <p>Playbook:</p>
  
  <pre><code>--&gt;cat until.yml
  ---
  
  - hosts: localhost
    gather_facts: no
    tasks:
  
      - name: "check command"
        shell: echo hello
        register: var
        until: var.stdout.find('hi') != -1
        retries: 5
        delay: 1
  </code></pre>
  
  <p>playbook output:</p>
  
  <pre><code> --&gt;ansible-playbook until.yml
  PLAY [localhost] *************************************************************************************************************************************************************************************************************************
  
  TASK [check command] ********************************************************************************************************************************************************************************************************
  FAILED - RETRYING: who triggered the playbook (5 retries left).
  FAILED - RETRYING: who triggered the playbook (4 retries left).
  FAILED - RETRYING: who triggered the playbook (3 retries left).
  FAILED - RETRYING: who triggered the playbook (2 retries left).
  FAILED - RETRYING: who triggered the playbook (1 retries left).
  fatal: [localhost]: FAILED! =&gt; {
      "attempts": 5,
      "changed": true,
      "cmd": "echo hello",
      "delta": "0:00:00.003004",
      "end": "2019-12-03 10:04:14.731488",
      "rc": 0,
      "start": "2019-12-03 10:04:14.728484"
  }
  
  STDOUT:
  
  hello
  
  
  PLAY RECAP *******************************************************************************************************************************************************************************************************************************
  localhost                  : ok=0    changed=0    unreachable=0    failed=1
  </code></pre>