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.

64 lines
2.8 KiB

  1. ---
  2. # Bootstrap heketi
  3. - name: "Get state of heketi service, deployment and pods."
  4. register: "initial_heketi_state"
  5. changed_when: false
  6. command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
  7. - name: "Bootstrap heketi."
  8. when:
  9. - "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Service']\"))|length == 0"
  10. - "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Deployment']\"))|length == 0"
  11. - "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Pod']\"))|length == 0"
  12. include_tasks: "bootstrap/deploy.yml"
  13. # Prepare heketi topology
  14. - name: "Get heketi initial pod state."
  15. register: "initial_heketi_pod"
  16. command: "{{ bin_dir }}/kubectl get pods --selector=deploy-heketi=pod,glusterfs=heketi-pod,name=deploy-heketi --output=json"
  17. changed_when: false
  18. - name: "Ensure heketi bootstrap pod is up."
  19. assert:
  20. that: "(initial_heketi_pod.stdout|from_json|json_query('items[*]'))|length == 1"
  21. - name: Store the initial heketi pod name
  22. set_fact:
  23. initial_heketi_pod_name: "{{ initial_heketi_pod.stdout|from_json|json_query(\"items[*].metadata.name|[0]\") }}"
  24. - name: "Test heketi topology."
  25. changed_when: false
  26. register: "heketi_topology"
  27. command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli --user admin --secret {{ heketi_admin_key }} topology info --json"
  28. - name: "Load heketi topology."
  29. when: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*]\")|flatten|length == 0"
  30. include_tasks: "bootstrap/topology.yml"
  31. # Provision heketi database volume
  32. - name: "Prepare heketi volumes."
  33. include_tasks: "bootstrap/volumes.yml"
  34. # Remove bootstrap heketi
  35. - name: "Tear down bootstrap."
  36. include_tasks: "bootstrap/tear-down.yml"
  37. # Prepare heketi storage
  38. - name: "Test heketi storage."
  39. command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
  40. changed_when: false
  41. register: "heketi_storage_state"
  42. # ensure endpoints actually exist before trying to move database data to it
  43. - name: "Create heketi storage."
  44. include_tasks: "bootstrap/storage.yml"
  45. vars:
  46. secret_query: "items[?metadata.name=='heketi-storage-secret' && kind=='Secret']"
  47. endpoints_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Endpoints']"
  48. service_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Service']"
  49. job_query: "items[?metadata.name=='heketi-storage-copy-job' && kind=='Job']"
  50. when:
  51. - "heketi_storage_state.stdout|from_json|json_query(secret_query)|length == 0"
  52. - "heketi_storage_state.stdout|from_json|json_query(endpoints_query)|length == 0"
  53. - "heketi_storage_state.stdout|from_json|json_query(service_query)|length == 0"
  54. - "heketi_storage_state.stdout|from_json|json_query(job_query)|length == 0"