restart_es_node.yml 1.3 KB

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