Prefix heketi kubectl calls with {{ bin_dir }}

This commit is contained in:
Simon Li 2018-07-30 16:44:02 +01:00 committed by Sascha Marcel Schmidt
parent 2bd8fbb2dd
commit 8ac57201a7
No known key found for this signature in database
GPG key ID: D1D6CE184437796D
12 changed files with 63 additions and 63 deletions

View file

@ -1,16 +1,16 @@
---
- register: "daemonset_state"
command: "kubectl get daemonset glusterfs -o=name --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get daemonset glusterfs -o=name --ignore-not-found=true"
changed_when: false
- name: "Deploy the GlusterFS DaemonSet"
when: "daemonset_state.stdout == \"\""
command: "kubectl create -f {{ kube_config_dir }}/glusterfs-daemonset.json"
command: "{{ bin_dir }}/kubectl create -f {{ kube_config_dir }}/glusterfs-daemonset.json"
- register: "daemonset_state"
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
changed_when: false
- name: "Wait for daemonset to become available."
register: "daemonset_state"
command: "kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get daemonset glusterfs --output=json --ignore-not-found=true"
changed_when: false
vars:
ready: "{{ daemonset_state.stdout|from_json|json_query(\"status.numberReady\") }}"
@ -26,29 +26,29 @@
include_tasks: "kubernetes/label.yml"
- register: "service_account_state"
command: "kubectl get serviceaccount heketi-service-account -o=name --ignore-not-found=true"
command: "{{ bin_dir }}/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 == \"\""
command: "kubectl create -f {{ kube_config_dir }}/heketi-service-account.json"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/kubectl get secret heketi-config-secret -o=name --ignore-not-found=true"
changed_when: false
- name: "Render Heketi secret configuration."
become: true
@ -57,8 +57,8 @@
dest: "{{ kube_config_dir }}/heketi.json"
- name: "Deploy Heketi config secret"
when: "secret_state.stdout == \"\""
command: "kubectl create secret generic heketi-config-secret --from-file={{ kube_config_dir }}/heketi.json"
command: "{{ bin_dir }}/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"
command: "{{ bin_dir }}/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." }

View file

@ -1,11 +1,11 @@
---
- register: "label_present"
command: "kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
changed_when: false
- name: "Assign storage label"
when: "label_present.stdout_lines|length == 0"
command: "kubectl label node {{ node }} storagenode=glusterfs"
command: "{{ bin_dir }}/kubectl label node {{ node }} storagenode=glusterfs"
- register: "label_present"
command: "kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get node --selector=storagenode=glusterfs,kubernetes.io/hostname={{ node }} --ignore-not-found=true"
changed_when: false
- assert: { that: "label_present|length > 0", msg: "Node {{ node }} has not been assigned with label storagenode=glusterfs." }

View file

@ -12,7 +12,7 @@
- name: "Test heketi setup."
register: "heketi_service_state"
command: "kubectl get service heketi -o=name --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get service heketi -o=name --ignore-not-found=true"
changed_when: false
- name: "Setup heketi."
@ -21,14 +21,14 @@
- name: "Test storage class."
changed_when: false
command: "kubectl get storageclass gluster --ignore-not-found=true --output=json"
command: "{{ bin_dir }}/kubectl get storageclass gluster --ignore-not-found=true --output=json"
register: "storageclass"
- name: "Setup storage class."
when: "storageclass.stdout == \"\""
include_tasks: "storageclass.yml"
- name: "Test storage class."
changed_when: false
command: "kubectl get storageclass gluster --ignore-not-found=true --output=json"
command: "{{ bin_dir }}/kubectl get storageclass gluster --ignore-not-found=true --output=json"
register: "storageclass"
- name: "Ensure storage class is up."
assert: { that: "storageclass.stdout != \"\"" }

View file

@ -3,7 +3,7 @@
- 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"
command: "{{ bin_dir }}/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"
@ -14,7 +14,7 @@
# Prepare heketi topology
- name: "Get heketi initial pod state."
register: "initial_heketi_pod"
command: "kubectl get pods --selector=deploy-heketi=pod,glusterfs=heketi-pod,name=deploy-heketi --output=json"
command: "{{ bin_dir }}/kubectl get pods --selector=deploy-heketi=pod,glusterfs=heketi-pod,name=deploy-heketi --output=json"
changed_when: false
- name: "Ensure heketi bootstrap pod is up."
assert:
@ -24,7 +24,7 @@
- name: "Test heketi topology."
changed_when: false
register: "heketi_topology"
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology info --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli 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"
@ -35,10 +35,10 @@
# Prepare heketi storage
- name: "Test heketi storage."
command: "kubectl get secrets,endpoints,services,jobs --output=json"
command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
changed_when: false
register: "heketi_storage_state"
- command: "kubectl get secrets,endpoints,services,jobs --output=json"
- command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
register: "job"
- name: "Create heketi storage."
include_tasks: "setup/storage.yml"

View file

@ -2,9 +2,9 @@
- 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"
command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
- name: "Create Heketi initial service and deployment"
command: "kubectl create -f {{ kube_config_dir }}/heketi-bootstrap.json"
command: "{{ bin_dir }}/kubectl create -f {{ kube_config_dir }}/heketi-bootstrap.json"
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"
@ -12,14 +12,14 @@
- 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"
command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
- name: "Wait for heketi bootstrap to complete."
changed_when: false
register: "initial_heketi_state"
vars:
pods_query: "items[?kind=='Pod'].status.conditions|[0][?type=='Ready'].status|[0]"
deployments_query: "items[?kind=='Deployment'].status.conditions|[0][?type=='Available'].status|[0]"
command: "kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
command: "{{ bin_dir }}/kubectl get services,deployments,pods --selector=deploy-heketi --output=json"
until:
- "initial_heketi_state.stdout|from_json|json_query(pods_query) == 'True'"
- "initial_heketi_state.stdout|from_json|json_query(deployments_query) == 'True'"

View file

@ -1,9 +1,9 @@
---
- name: "Create long term Heketi instance."
command: "kubectl create -f {{ kube_config_dir }}/heketi-deployment.json"
command: "{{ bin_dir }}/kubectl create -f {{ kube_config_dir }}/heketi-deployment.json"
- name: "Get heketi deployment state."
register: "heketi_deployment_state"
command: "kubectl get deployment heketi -o=name --ignore-not-found=true"
command: "{{ bin_dir }}/kubectl get deployment heketi -o=name --ignore-not-found=true"
changed_when: false
- name: "Ensure heketi is up and running."
assert: { that: "heketi_deployment_state.stdout != \"\"", message: "Heketi deployment did not succeed." }

View file

@ -1,10 +1,10 @@
---
- name: "Test heketi storage."
command: "kubectl get secrets,endpoints,services,jobs --output=json"
command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
changed_when: false
register: "heketi_storage_state"
- name: "Create heketi storage."
command: "kubectl create -f {{ kube_config_dir }}/heketi-storage.json"
command: "{{ bin_dir }}/kubectl create -f {{ kube_config_dir }}/heketi-storage.json"
vars:
secret_query: "items[?metadata.name=='heketi-storage-secret' && kind=='Secret']"
endpoints_query: "items[?metadata.name=='heketi-storage-endpoints' && kind=='Endpoints']"
@ -16,10 +16,10 @@
- "heketi_storage_state.stdout|from_json|json_query(service_query)|length == 0"
- "heketi_storage_state.stdout|from_json|json_query(job_query)|length == 0"
register: "heketi_storage_result"
- command: "kubectl get secrets,endpoints,services,jobs --output=json"
- command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
register: "heketi_storage_state"
- name: "Get state of heketi storage service, endpoint, secret and job."
command: "kubectl get secrets,endpoints,services,jobs --output=json"
command: "{{ bin_dir }}/kubectl get secrets,endpoints,services,jobs --output=json"
changed_when: false
register: "heketi_storage_state"
vars:

View file

@ -1,13 +1,13 @@
---
- name: "Get existing Heketi deploy resources."
command: "kubectl get all --selector=\"deploy-heketi\" -o=json"
command: "{{ bin_dir }}/kubectl get all --selector=\"deploy-heketi\" -o=json"
register: "heketi_resources"
changed_when: false
- name: "Delete bootstrap Heketi."
command: "kubectl delete all,service,jobs,deployment,secret --selector=\"deploy-heketi\""
command: "{{ bin_dir }}/kubectl delete all,service,jobs,deployment,secret --selector=\"deploy-heketi\""
when: "heketi_resources.stdout|from_json|json_query('items[*]')|length > 0"
- name: "Ensure there is nothing left over."
command: "kubectl get all,service,jobs,deployment,secret --selector=\"deploy-heketi\" -o=json"
command: "{{ bin_dir }}/kubectl get all,service,jobs,deployment,secret --selector=\"deploy-heketi\" -o=json"
register: "heketi_result"
until: "heketi_result.stdout|from_json|json_query('items[*]')|length == 0"
retries: 60

View file

@ -1,7 +1,7 @@
---
- name: "Get heketi topology."
register: "heketi_topology"
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology info --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology info --json"
- name: "Render heketi topology template."
become: true
vars: { nodes: "{{ groups['heketi-node'] }}" }
@ -9,13 +9,13 @@
src: "topology.json.j2"
dest: "{{ kube_config_dir }}/topology.json"
- name: "Copy topology configuration into container."
command: "kubectl cp {{ kube_config_dir }}/topology.json {{ initial_heketi_pod_name }}:/tmp/topology.json"
command: "{{ bin_dir }}/kubectl cp {{ kube_config_dir }}/topology.json {{ initial_heketi_pod_name }}:/tmp/topology.json"
- name: "Load heketi topology."
when: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*]\")|flatten|length == 0"
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology load --json=/tmp/topology.json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology load --json=/tmp/topology.json"
- name: "Get heketi topology."
register: "heketi_topology"
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology info --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli topology info --json"
until: "heketi_topology.stdout|from_json|json_query(\"clusters[*].nodes[*].devices[?state=='online'].id\")|flatten|length == groups['heketi-node']|length"
retries: 60
delay: 5

View file

@ -1,11 +1,11 @@
---
- name: "Get heketi volume ids."
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume list --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume list --json"
changed_when: false
register: "heketi_volumes"
- name: "Get heketi volumes."
changed_when: false
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume info {{ volume_id }} --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume info {{ volume_id }} --json"
with_items: "{{ heketi_volumes.stdout|from_json|json_query(\"volumes[*]\") }}"
loop_control: { loop_var: "volume_id" }
register: "volumes_information"
@ -16,18 +16,18 @@
vars: { volume: "{{ volume_information.stdout|from_json }}" }
when: "volume.name == 'heketidbstorage'"
- name: "Provision database volume."
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli setup-openshift-heketi-storage"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli setup-openshift-heketi-storage"
when: "heketi_database_volume_exists is undefined"
- name: "Copy configuration from pod."
become: true
command: "/usr/local/bin/kubectl cp {{ initial_heketi_pod_name }}:/heketi-storage.json {{ kube_config_dir }}/heketi-storage.json"
command: "{{ bin_dir }}/kubectl cp {{ initial_heketi_pod_name }}:/heketi-storage.json {{ kube_config_dir }}/heketi-storage.json"
- name: "Get heketi volume ids."
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume list --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume list --json"
changed_when: false
register: "heketi_volumes"
- name: "Get heketi volumes."
changed_when: false
command: "kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume info {{ volume_id }} --json"
command: "{{ bin_dir }}/kubectl exec {{ initial_heketi_pod_name }} -- heketi-cli volume info {{ volume_id }} --json"
with_items: "{{ heketi_volumes.stdout|from_json|json_query(\"volumes[*]\") }}"
loop_control: { loop_var: "volume_id" }
register: "volumes_information"

View file

@ -1,10 +1,10 @@
---
- name: "Test storage class."
command: "kubectl get storageclass gluster --ignore-not-found=true --output=json"
command: "{{ bin_dir }}/kubectl get storageclass gluster --ignore-not-found=true --output=json"
register: "storageclass"
changed_when: false
- name: "Test heketi service."
command: "kubectl get service heketi --ignore-not-found=true --output=json"
command: "{{ bin_dir }}/kubectl get service heketi --ignore-not-found=true --output=json"
register: "heketi_service"
changed_when: false
- name: "Ensure heketi service is available."
@ -18,4 +18,4 @@
dest: "{{ kube_config_dir }}/storageclass.yml"
- name: "Setup storage class."
when: "storageclass.stdout == \"\""
command: "kubectl create -f {{ kube_config_dir }}/storageclass.yml"
command: "{{ bin_dir }}/kubectl create -f {{ kube_config_dir }}/storageclass.yml"

View file

@ -1,52 +1,52 @@
---
- name: "Remove storage class."
command: "kubectl delete storageclass gluster"
command: "{{ bin_dir }}/kubectl delete storageclass gluster"
ignore_errors: true
- name: "Tear down heketi."
command: "kubectl delete all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-pod\""
command: "{{ bin_dir }}/kubectl delete all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-pod\""
ignore_errors: true
- name: "Tear down heketi."
command: "kubectl delete all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-deployment\""
command: "{{ bin_dir }}/kubectl delete all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-deployment\""
ignore_errors: true
- name: "Tear down bootstrap."
include_tasks: "../provision/tasks/setup/tear-down-bootstrap.yml"
- name: "Ensure there is nothing left over."
command: "kubectl get all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-pod\" -o=json"
command: "{{ bin_dir }}/kubectl get all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-pod\" -o=json"
register: "heketi_result"
until: "heketi_result.stdout|from_json|json_query('items[*]')|length == 0"
retries: 60
delay: 5
- name: "Ensure there is nothing left over."
command: "kubectl get all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-deployment\" -o=json"
command: "{{ bin_dir }}/kubectl get all,service,jobs,deployment,secret --selector=\"glusterfs=heketi-deployment\" -o=json"
register: "heketi_result"
until: "heketi_result.stdout|from_json|json_query('items[*]')|length == 0"
retries: 60
delay: 5
- name: "Tear down glusterfs."
command: "kubectl delete daemonset.extensions/glusterfs"
command: "{{ bin_dir }}/kubectl delete daemonset.extensions/glusterfs"
ignore_errors: true
- name: "Remove heketi storage service."
command: "kubectl delete service heketi-storage-endpoints"
command: "{{ bin_dir }}/kubectl delete service heketi-storage-endpoints"
ignore_errors: true
- name: "Remove heketi gluster role binding"
command: "kubectl delete clusterrolebinding heketi-gluster-admin"
command: "{{ bin_dir }}/kubectl delete clusterrolebinding heketi-gluster-admin"
ignore_errors: true
- name: "Remove heketi config secret"
command: "kubectl delete secret heketi-config-secret"
command: "{{ bin_dir }}/kubectl delete secret heketi-config-secret"
ignore_errors: true
- name: "Remove heketi db backup"
command: "kubectl delete secret heketi-db-backup"
command: "{{ bin_dir }}/kubectl delete secret heketi-db-backup"
ignore_errors: true
- name: "Remove heketi service account"
command: "kubectl delete serviceaccount heketi-service-account"
command: "{{ bin_dir }}/kubectl delete serviceaccount heketi-service-account"
ignore_errors: true
- name: "Get secrets"
command: "kubectl get secrets --output=\"json\""
command: "{{ bin_dir }}/kubectl get secrets --output=\"json\""
register: "secrets"
changed_when: false
- name: "Remove heketi storage secret"
vars: { storage_query: "items[?metadata.annotations.\"kubernetes.io/service-account.name\"=='heketi-service-account'].metadata.name|[0]" }
command: "kubectl delete secret {{ secrets.stdout|from_json|json_query(storage_query) }}"
command: "{{ bin_dir }}/kubectl delete secret {{ secrets.stdout|from_json|json_query(storage_query) }}"
when: "storage_query is defined"
ignore_errors: true
- name: "Prepare cluster disks."