<p>I have an Ansible task almost identical to the top answer here: <a href="https://stackoverflow.com/questions/53198576/ansible-playbook-wait-until-all-pods-running">Ansible playbook wait until all pods running</a></p>
<pre class="lang-yaml prettyprint-override"><code>- name: Wait for all control-plane pods become created
  shell: &quot;kubectl get po --namespace=kube-system --selector tier=control-plane --output=jsonpath='{.items[*].metadata.name}'&quot;
  register: control_plane_pods_created
  until: item in control_plane_pods_created.stdout
  retries: 10
  delay: 30
  with_items:
    - etcd
    - kube-apiserver
    - kube-controller-manager
    - kube-scheduler

- name: Wait for control-plane pods become ready
  shell: &quot;kubectl wait --namespace=kube-system --for=condition=Ready pods --selector tier=control-plane --timeout=600s&quot;
  register: control_plane_pods_ready

- debug: var=control_plane_pods_ready.stdout_lines
</code></pre>
<p>As shown in his example it prints 'FAILED' 3 times:</p>
<pre class="lang-json prettyprint-override"><code>TASK [Wait for all control-plane pods become created] ******************************
FAILED - RETRYING: Wait all control-plane pods become created (10 retries left).
FAILED - RETRYING: Wait all control-plane pods become created (9 retries left).
FAILED - RETRYING: Wait all control-plane pods become created (8 retries left).
changed: [localhost -&gt; localhost] =&gt; (item=etcd)
changed: [localhost -&gt; localhost] =&gt; (item=kube-apiserver)
changed: [localhost -&gt; localhost] =&gt; (item=kube-controller-manager)
changed: [localhost -&gt; localhost] =&gt; (item=kube-scheduler)

TASK [Wait for control-plane pods become ready] ********************************
changed: [localhost -&gt; localhost]

TASK [debug] *******************************************************************
ok: [localhost] =&gt; {
    &quot;control_plane_pods_ready.stdout_lines&quot;: [
        &quot;pod/etcd-localhost.localdomain condition met&quot;, 
        &quot;pod/kube-apiserver-localhost.localdomain condition met&quot;, 
        &quot;pod/kube-controller-manager-localhost.localdomain condition met&quot;, 
        &quot;pod/kube-scheduler-localhost.localdomain condition met&quot;
    ]    
}
</code></pre>
<p>For my implementation, the loop fails more than 3 times more like 20 times... so it clogs up my logs... but this is expected behaviour.</p>
<p>So how can I only print 'FAILED' once all the retries have been used up?</p>
<p>I hope my question makes sense,
Thanks</p>

<blockquote>
<p><em>How can I only print 'FAILED - RETRYING' once all the retries have been used up?</em></p>
</blockquote>
<p>I understand that you are referencing to <code>until</code> <code>retries</code> and like to <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#retrying-a-task-until-a-condition-is-met" rel="nofollow noreferrer">Retrying a task until a condition is met</a> and the message <code>FAILED</code> belongs to the loop and not the final task result.</p>
<p>Running a short fail test</p>
<pre class="lang-yaml prettyprint-override"><code>---
- hosts: localhost
  become: false
  gather_facts: false

  tasks:

  - name: Show fail test
    shell:
      cmd: exit 1 # to fail
    register: result
    # inner loop
    until: result.rc == 0 # which will never happen
    retries: 3 # times therefore
    delay: 1 # second
    # outer
    loop: [1, 2, 3] # times over 
    failed_when: item == 3 and result.rc != 0 # on last outer loop run only
    no_log: true # for outer loop content
</code></pre>
<p>resulting into an output of</p>
<pre class="lang-yaml prettyprint-override"><code>PLAY [localhost] **********************************
FAILED - RETRYING: Show fail test (3 retries left).
FAILED - RETRYING: Show fail test (2 retries left).
FAILED - RETRYING: Show fail test (1 retries left).

TASK [Show fail test] *****************************
changed: [localhost] =&gt; (item=None)
FAILED - RETRYING: Show fail test (3 retries left).
FAILED - RETRYING: Show fail test (2 retries left).
FAILED - RETRYING: Show fail test (1 retries left).
changed: [localhost] =&gt; (item=None)
FAILED - RETRYING: Show fail test (3 retries left).
FAILED - RETRYING: Show fail test (2 retries left).
FAILED - RETRYING: Show fail test (1 retries left).
failed: [localhost] (item=None) =&gt; changed=true
  attempts: 3
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
fatal: [localhost]: FAILED! =&gt; changed=true
  censored: 'the output has been hidden due to the fact that ''no_log: true'' was specified for this result'
</code></pre>
<p>it seems that it is not possible to suppress the interim message of Ansible's <code>until</code> <code>retries</code> loop on playbook level, neither with <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html#defining-failure" rel="nofollow noreferrer">Defining failure</a> nor by <a href="https://docs.ansible.com/ansible/latest/reference_appendices/logging.html#protecting-sensitive-data-with-no-log" rel="nofollow noreferrer">Protecting sensitive data with <code>no_log</code></a> or <a href="https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#limiting-loop-output-with-label" rel="nofollow noreferrer">Limiting loop output</a>.</p>
<blockquote>
<p><em>...  but this is expected behaviour.</em></p>
</blockquote>
<p>Right, unless you are not addressing <a href="https://docs.ansible.com/ansible/devel/plugins/callback.html" rel="nofollow noreferrer">Callback plugins</a> and <a href="https://docs.ansible.com/ansible/devel/plugins/callback.html#setting-a-callback-plugin-for-ansible-playbook" rel="nofollow noreferrer">Setting a (other) callback plugin for ansible-playbook</a> or <a href="https://docs.ansible.com/ansible/devel/dev_guide/developing_plugins.html#developing-callbacks" rel="nofollow noreferrer">Developing (own) Callback plugin</a> the message will remain.</p>
<p><strong>Similar Q&amp;A</strong></p>
<ul>
<li><a href="https://stackoverflow.com/a/48727195/6771046">How to change the interim message of Ansible's <code>until</code> <code>retries</code> loop?</a></li>
</ul>
<p><strong>Further Information</strong></p>
<ul>
<li><a href="https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/default.py#L374" rel="nofollow noreferrer"><code>ansible/plugins/callback/default.py</code></a></li>
</ul>
<p><strong>Possible Solution</strong></p>
<ul>
<li>Ansible Issue #<a href="https://github.com/ansible/ansible/issues/32584" rel="nofollow noreferrer">32584</a></li>
<li><a href="https://docs.ansible.com/ansible/latest/collections/community/general/diy_callback.html" rel="nofollow noreferrer"><code>diy</code> callback – Customize the output</a></li>
</ul>
