I have this ansible (working) playbook that looks at the output of kubectl get pods -o json
until the pod is in the Running
state. Now I want to exten
I would try something like this (works for me):
tasks:
- name: wait for pods to come up
shell: kubectl get pods -o json
register: kubectl_get_pods
until: kubectl_get_pods.stdout|from_json|json_query('items[*].status.phase')|unique == ["Running"]
You are basically getting all the statuses for all the pods and combining them into a unique list, and then it won't complete until that list is ["Running"]
. So for example, if all your pods are not running you will get something like ["Running", "Starting"]
.