restart_es_node.yml 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. ---
  2. - name: "Rolling out new pod(s) for {{ _es_node }}"
  3. command: >
  4. {{ openshift_client_binary }} rollout latest {{ _es_node }} -n {{ openshift_logging_elasticsearch_namespace }}
  5. - when: not _skip_healthcheck | bool
  6. name: "Waiting for {{ _es_node }} to finish scaling up"
  7. oc_obj:
  8. state: list
  9. name: "{{ _es_node }}"
  10. namespace: "{{ openshift_logging_elasticsearch_namespace }}"
  11. kind: dc
  12. register: _dc_output
  13. until:
  14. - _dc_output.results.results[0].status is defined
  15. - _dc_output.results.results[0].status.readyReplicas is defined
  16. - _dc_output.results.results[0].status.readyReplicas > 0
  17. - _dc_output.results.results[0].status.updatedReplicas is defined
  18. - _dc_output.results.results[0].status.updatedReplicas > 0
  19. retries: 60
  20. delay: 30
  21. - when: not _skip_healthcheck | bool
  22. name: Gettings name(s) of replica pod(s)
  23. command: >
  24. {{ openshift_client_binary }} get pods -l deploymentconfig={{ _es_node }} -n {{ openshift_logging_elasticsearch_namespace }} -o jsonpath={.items[*].metadata.name}
  25. register: _pods
  26. - when: not _skip_healthcheck | bool
  27. name: "Waiting for ES to be ready for {{ _es_node }}"
  28. shell: >
  29. {{ openshift_client_binary }} exec "{{ _pod }}" -c elasticsearch -n "{{ openshift_logging_elasticsearch_namespace }}" -- es_cluster_health
  30. with_items: "{{ _pods.stdout.split(' ') }}"
  31. loop_control:
  32. loop_var: _pod
  33. register: _pod_status
  34. until: (_pod_status.stdout | from_json)['status'] in ['green', 'yellow']
  35. retries: 60
  36. delay: 10
  37. changed_when: false