2019-04-01 09:38:33 +00:00
|
|
|
---
|
2018-06-25 11:23:20 +00:00
|
|
|
# Bootstrap heketi
|
2018-06-27 10:30:14 +00:00
|
|
|
- name: "Get state of heketi service, deployment and pods."
|
|
|
|
register: "initial_heketi_state"
|
|
|
|
changed_when: false
|
2018-07-30 15:44:02 +00:00
|
|
|
command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
|
2019-05-16 07:27:43 +00:00
|
|
|
|
2018-06-25 11:23:20 +00:00
|
|
|
- name: "Bootstrap heketi."
|
2018-06-27 10:30:14 +00:00
|
|
|
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"
|
2018-08-08 12:22:50 +00:00
|
|
|
include_tasks: "bootstrap/deploy.yml"
|
2018-06-25 11:23:20 +00:00
|
|
|
|
|
|
|
# Prepare heketi topology
|
2018-07-25 14:42:30 +00:00
|
|
|
- name: "Get heketi initial pod state."
|
|
|
|
register: "initial_heketi_pod"
|
2018-07-30 15:44:02 +00:00
|
|
|
command: "{{ bin_dir }}/kubectl get pods --selector=deploy-heketi=pod,glusterfs=heketi-pod,name=deploy-heketi --output=json"
|
2018-07-25 14:42:30 +00:00
|
|
|
changed_when: false
|
2019-05-16 07:27:43 +00:00
|
|
|
|
2018-07-25 14:42:30 +00:00
|
|
|
- name: "Ensure heketi bootstrap pod is up."
|
|
|
|
assert:
|
|
|
|
that: "(initial_heketi_pod.stdout|from_json|json_query('items[*]'))|length == 1"
|
2019-05-16 07:27:43 +00:00
|
|
|
|
|
|
|
- name: Store the initial heketi pod name
|
|
|
|
set_fact:
|
2018-07-25 14:42:30 +00:00
|
|
|
initial_heketi_pod_name: "{{ initial_heketi_pod.stdout|from_json|json_query(\"items[*].metadata.name|[0]\") }}"
|
2019-05-16 07:27:43 +00:00
|
|
|
|
2018-06-25 11:23:20 +00:00
|
|
|
- name: "Test heketi topology."
|
|
|
|
changed_when: false
|
|
|
|
register: "heketi_topology"
|
2018-09-05 13:59:56 +00:00
|
|
|
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli --user admin --secret {{ heketi_admin_key }} topology info --json"
|
2019-05-16 07:27:43 +00:00
|
|
|
|
2018-06-25 11:23:20 +00:00
|
|
|
- name: "Load heketi topology."
|
|
|
|
when: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*]\")|flatten|length == 0"
|
2018-08-08 12:22:50 +00:00
|
|
|
include_tasks: "bootstrap/topology.yml"
|
2018-06-25 11:23:20 +00:00
|
|
|
|
|
|
|
# Provision heketi database volume
|
|
|
|
- name: "Prepare heketi volumes."
|
2018-08-08 12:22:50 +00:00
|
|
|
include_tasks: "bootstrap/volumes.yml"
|
2018-06-25 11:23:20 +00:00
|
|
|
|
2018-09-05 14:03:32 +00:00
|
|
|
# Remove bootstrap heketi
|
|
|
|
- name: "Tear down bootstrap."
|
|
|
|
include_tasks: "bootstrap/tear-down.yml"
|
|
|
|
|
2018-06-25 11:23:20 +00:00
|
|
|
# Prepare heketi storage
|
|
|
|
- name: "Test heketi storage."
|
2018-07-30 15:44:02 +00:00
|
|
|
command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
|
2018-06-25 11:23:20 +00:00
|
|
|
changed_when: false
|
|
|
|
register: "heketi_storage_state"
|
2019-05-16 07:27:43 +00:00
|
|
|
|
2018-09-05 14:03:32 +00:00
|
|
|
# ensure endpoints actually exist before trying to move database data to it
|
2018-06-25 11:23:20 +00:00
|
|
|
- name: "Create heketi storage."
|
2018-08-08 12:22:50 +00:00
|
|
|
include_tasks: "bootstrap/storage.yml"
|
2018-06-25 11:23:20 +00:00
|
|
|
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"
|