2018-06-25 11:23:20 +00:00
|
|
|
---
|
|
|
|
- register: "daemonset_state"
|
|
|
|
command: "kubectl get daemonset glusterfs -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- name: "Deploy the GlusterFS DaemonSet"
|
|
|
|
when: "daemonset_state.stdout == \"\""
|
2018-07-25 14:42:30 +00:00
|
|
|
command: "kubectl create -f {{ kube_config_dir }}/glusterfs-daemonset.json"
|
2018-06-25 11:23:20 +00:00
|
|
|
- register: "daemonset_state"
|
2018-07-05 00:14:36 +00:00
|
|
|
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
|
2018-07-05 12:18:27 +00:00
|
|
|
changed_when: false
|
2018-07-05 00:14:36 +00:00
|
|
|
- name: "Wait for daemonset to become available."
|
|
|
|
register: "daemonset_state"
|
|
|
|
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
|
2018-06-25 11:23:20 +00:00
|
|
|
changed_when: false
|
2018-07-05 00:14:36 +00:00
|
|
|
vars:
|
|
|
|
ready: "{{ daemonset_state.stdout|from_json|json_query(\"status.numberReady\") }}"
|
|
|
|
desired: "{{ daemonset_state.stdout|from_json|json_query(\"status.desiredNumberScheduled\") }}"
|
|
|
|
until: "ready == desired"
|
|
|
|
retries: 60
|
|
|
|
delay: 5
|
2018-06-25 11:23:20 +00:00
|
|
|
|
|
|
|
- name: "Label Gluster nodes"
|
|
|
|
with_items: "{{ groups['heketi-node'] }}"
|
|
|
|
loop_control:
|
|
|
|
loop_var: "node"
|
|
|
|
include_tasks: "kubernetes/label.yml"
|
|
|
|
|
|
|
|
- register: "service_account_state"
|
|
|
|
command: "kubectl get serviceaccount heketi-service-account -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- name: "Deploy the Heketi service account"
|
|
|
|
when: "service_account_state.stdout == \"\""
|
2018-07-25 14:42:30 +00:00
|
|
|
command: "kubectl create -f {{ kube_config_dir }}/heketi-service-account.json"
|
2018-06-25 11:23:20 +00:00
|
|
|
- register: "service_account_state"
|
|
|
|
command: "kubectl get serviceaccount heketi-service-account -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- assert: { that: "service_account_state.stdout != \"\"", message: "Heketi service account is not present." }
|
|
|
|
|
|
|
|
- register: "clusterrolebinding_state"
|
|
|
|
command: "kubectl get clusterrolebinding heketi-gluster-admin -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- name: "Deploy cluster role binding."
|
|
|
|
when: "clusterrolebinding_state.stdout == \"\""
|
|
|
|
command: "kubectl create clusterrolebinding heketi-gluster-admin --clusterrole=edit --serviceaccount=default:heketi-service-account"
|
|
|
|
- register: "clusterrolebinding_state"
|
|
|
|
command: "kubectl get clusterrolebinding heketi-gluster-admin -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- assert: { that: "clusterrolebinding_state.stdout != \"\"", message: "Cluster role binding is not present." }
|
|
|
|
|
|
|
|
- register: "secret_state"
|
|
|
|
command: "kubectl get secret heketi-config-secret -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- name: "Render Heketi secret configuration."
|
2018-07-25 14:42:30 +00:00
|
|
|
become: true
|
2018-06-25 11:23:20 +00:00
|
|
|
template:
|
|
|
|
src: "heketi.json.j2"
|
2018-07-25 14:42:30 +00:00
|
|
|
dest: "{{ kube_config_dir }}/heketi.json"
|
2018-06-25 11:23:20 +00:00
|
|
|
- name: "Deploy Heketi config secret"
|
|
|
|
when: "secret_state.stdout == \"\""
|
2018-07-25 14:42:30 +00:00
|
|
|
command: "kubectl create secret generic heketi-config-secret --from-file={{ kube_config_dir }}/heketi.json"
|
2018-06-25 11:23:20 +00:00
|
|
|
- register: "secret_state"
|
|
|
|
command: "kubectl get secret heketi-config-secret -o=name --ignore-not-found=true"
|
|
|
|
changed_when: false
|
|
|
|
- assert: { that: "secret_state.stdout != \"\"", message: "Heketi config secret is not present." }
|