check.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. # Check the cluster is healthy
  3. - include: check_cluster_health.yml
  4. # Check if the member has v3 data already
  5. # Run the migration only if the data are v2
  6. - name: Check if there are any v3 data
  7. command: >
  8. etcdctl --cert {{ etcd_peer_cert_file }} --key {{ etcd_peer_key_file }} --cacert {{ etcd_peer_ca_file }} --endpoints 'https://{{ etcd_peer }}:{{ etcd_client_port }}' get "" --from-key --keys-only -w json --limit 1
  9. environment:
  10. ETCDCTL_API: 3
  11. register: l_etcdctl_output
  12. - fail:
  13. msg: "Unable to get a number of v3 keys"
  14. when: l_etcdctl_output.rc != 0
  15. - fail:
  16. msg: "The etcd has at least one v3 key"
  17. when: "'count' in (l_etcdctl_output.stdout | from_json) and (l_etcdctl_output.stdout | from_json).count != 0"
  18. # TODO(jchaloup): once the until loop can be used over include/block,
  19. # remove the repetive code
  20. # - until loop not supported over include statement (nor block)
  21. # https://github.com/ansible/ansible/issues/17098
  22. # - with_items not supported over block
  23. # Check the cluster status for the first time
  24. - include: check_cluster_status.yml
  25. # Check the cluster status for the second time
  26. - block:
  27. - debug:
  28. msg: "l_etcd_cluster_status_ok: {{ l_etcd_cluster_status_ok }}"
  29. - name: Wait a while before another check
  30. pause:
  31. seconds: 5
  32. when: not l_etcd_cluster_status_ok | bool
  33. - include: check_cluster_status.yml
  34. when: not l_etcd_cluster_status_ok | bool
  35. # Check the cluster status for the third time
  36. - block:
  37. - debug:
  38. msg: "l_etcd_cluster_status_ok: {{ l_etcd_cluster_status_ok }}"
  39. - name: Wait a while before another check
  40. pause:
  41. seconds: 5
  42. when: not l_etcd_cluster_status_ok | bool
  43. - include: check_cluster_status.yml
  44. when: not l_etcd_cluster_status_ok | bool