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

65 lines
2.9 KiB
YAML
Raw Normal View History

---
- 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"
- register: "daemonset_state"
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
2018-07-05 12:18:27 +00:00
changed_when: false
- name: "Wait for daemonset to become available."
register: "daemonset_state"
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
changed_when: false
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
- 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"
- 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
template:
src: "heketi.json.j2"
2018-07-25 14:42:30 +00:00
dest: "{{ kube_config_dir }}/heketi.json"
- 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"
- 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." }