You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

  1. ---
  2. - name: Testcases checking pods
  3. hosts: kube_control_plane[0]
  4. tasks:
  5. - name: Force binaries directory for Flatcar Container Linux by Kinvolk
  6. set_fact:
  7. bin_dir: "/opt/bin"
  8. when: ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
  9. - name: Force binaries directory for other hosts
  10. set_fact:
  11. bin_dir: "/usr/local/bin"
  12. when: not ansible_os_family in ["Flatcar", "Flatcar Container Linux by Kinvolk"]
  13. - import_role: # noqa name[missing]
  14. name: cluster-dump
  15. - name: Check kubectl output
  16. command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
  17. changed_when: false
  18. register: get_pods
  19. no_log: true
  20. - debug: # noqa name[missing]
  21. msg: "{{ get_pods.stdout.split('\n') }}"
  22. - name: Check that all pods are running and ready
  23. command: "{{ bin_dir }}/kubectl get pods --all-namespaces --no-headers -o yaml"
  24. changed_when: false
  25. register: run_pods_log
  26. until:
  27. # Check that all pods are running
  28. - '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.phase") | unique | list == ["Running"]'
  29. # Check that all pods are ready
  30. - '(run_pods_log.stdout | from_yaml)["items"] | map(attribute = "status.containerStatuses") | map("map", attribute = "ready") | map("min") | min'
  31. retries: 30
  32. delay: 10
  33. failed_when: false
  34. no_log: true
  35. - name: Check kubectl output
  36. command: "{{ bin_dir }}/kubectl get pods --all-namespaces -owide"
  37. changed_when: false
  38. register: get_pods
  39. no_log: true
  40. - debug: # noqa name[missing]
  41. msg: "{{ get_pods.stdout.split('\n') }}"
  42. failed_when: not run_pods_log is success