I have an Ansible task almost identical to the top answer here: Ansible playbook wait until all pods running
- name: Wait for all control-plane pods become created
shell: "kubectl get po --namespace=kube-system --selector tier=control-plane --output=jsonpath='{.items[*].metadata.name}'"
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: "kubectl wait --namespace=kube-system --for=condition=Ready pods --selector tier=control-plane --timeout=600s"
register: control_plane_pods_ready
- debug: var=control_plane_pods_ready.stdout_lines
As shown in his example it prints 'FAILED' 3 times:
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 -> localhost] => (item=etcd)
changed: [localhost -> localhost] => (item=kube-apiserver)
changed: [localhost -> localhost] => (item=kube-controller-manager)
changed: [localhost -> localhost] => (item=kube-scheduler)
TASK [Wait for control-plane pods become ready] ********************************
changed: [localhost -> localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"control_plane_pods_ready.stdout_lines": [
"pod/etcd-localhost.localdomain condition met",
"pod/kube-apiserver-localhost.localdomain condition met",
"pod/kube-controller-manager-localhost.localdomain condition met",
"pod/kube-scheduler-localhost.localdomain condition met"
]
}
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.
So how can I only print 'FAILED' once all the retries have been used up?
I hope my question makes sense, Thanks