restart_es_node.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  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. retries: 60
  17. delay: 30
  18. - name: Gettings name(s) of replica pod(s)
  19. command: >
  20. oc get pods -l deploymentconfig={{ _es_node }} -n {{ openshift_logging_elasticsearch_namespace }} -o jsonpath={.items[*].metadata.name}
  21. register: _pods
  22. - name: "Waiting for ES to be ready for {{ _es_node }}"
  23. shell: >
  24. oc exec "{{ _pod }}" -c elasticsearch -n "{{ openshift_logging_elasticsearch_namespace }}" -- {{ __es_local_curl }} https://localhost:9200/_cat/health | cut -d' ' -f4
  25. with_items: "{{ _pods.stdout.split(' ') }}"
  26. loop_control:
  27. loop_var: _pod
  28. register: _pod_status
  29. until: _pod_status.stdout in ['green', 'yellow']
  30. retries: 60
  31. delay: 5
  32. changed_when: false