c12s-kubespray/contrib/network-storage/heketi/roles/provision/tasks/setup.yml

54 lines
2.3 KiB
YAML
Raw Normal View History

---
# Bootstrap heketi
- name: "Get state of heketi service, deployment and pods."
register: "initial_heketi_state"
changed_when: false
command: "kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
- name: "Bootstrap heketi."
when:
- "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Service']\"))|length == 0"
- "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Deployment']\"))|length == 0"
- "(initial_heketi_state.stdout|from_json|json_query(\"items[?kind=='Pod']\"))|length == 0"
include_tasks: "setup/boot.yml"
- name: "Test rest endpoint port."
wait_for: { host: "localhost", port: "48080", state: "absent" }
- name: "Start REST endpoint."
include_tasks: "setup/rest.yml"
# Prepare heketi topology
- name: "Test heketi topology."
changed_when: false
register: "heketi_topology"
command: "heketi-cli -s http://localhost:48080 topology info --json"
- name: "Load heketi topology."
when: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*]\")|flatten|length == 0"
include_tasks: "setup/topology.yml"
# Provision heketi database volume
- name: "Prepare heketi volumes."
include_tasks: "setup/volumes.yml"
# Prepare heketi storage
- name: "Test heketi storage."
command: "kubectl get secrets,endpoints,services,jobs --output=json"
changed_when: false
register: "heketi_storage_state"
- name: "Create heketi storage."
include_tasks: "setup/storage.yml"
vars:
secret_query: "items[?metadata.name=='heketi-storage-secret' && kind=='Secret']"
endpoints_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Endpoints']"
service_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Service']"
job_query: "items[?metadata.name=='heketi-storage-copy-job' && kind=='Job']"
when:
- "heketi_storage_state.stdout|from_json|json_query(secret_query)|length == 0"
- "heketi_storage_state.stdout|from_json|json_query(endpoints_query)|length == 0"
- "heketi_storage_state.stdout|from_json|json_query(service_query)|length == 0"
- "heketi_storage_state.stdout|from_json|json_query(job_query)|length == 0"
# Finalize setup
- name: "Tear down bootstrap."
include_tasks: "setup/tear-down-bootstrap.yml"
- name: "Setup final heketi instance."
include_tasks: "setup/heketi.yml"