---
- name: taint gluster nodes
  command: >
    kubectl taint node -l storagenode=glusterfs dedicated=fileserver:NoSchedule

- name: create heketi yaml directory
  file:
    path: ~/.kubernetes-yaml/heketi/
    state: directory
    mode: 0755

- name: copy heketi configuration
  copy:
    src: heketi-server.yml
    dest: "~/.kubernetes-yaml/heketi/heketi-server.yml"

- name: start heketi
  command: >
    kubectl apply -f
    $HOME/.kubernetes-yaml/heketi/heketi-server.yml

- name: wait for heketi to be Running
  command: >
    kubectl get pods --namespace=storage-heketi
    -o jsonpath='{.items[?(@.spec.containers[*].name=="heketi")].status.phase}'
  register: get_phase
  until: get_phase.stdout | match('^(Running\s)*Running$')
  # Wait for 10 minutes
  retries: 120
  delay: 5

- name: wait for heketi to be Ready
  command: >
    kubectl get pods --namespace=storage-heketi
    -o jsonpath='{.items[?(@.spec.containers[*].name=="heketi")].status.containerStatuses[*].ready}'
  register: get_is_ready
  until: get_is_ready.stdout | match( '^(true\s)*true$' )
  # Wait for 10 minutes
  retries: 120
  delay: 5

---
- name: taint gluster nodes
  command: >
    kubectl taint node --overwrite=true -l storagenode=glusterfs dedicated=fileserver:NoSchedule

- name: create heketi yaml directory
  file:
    path: ~/.kubernetes-yaml/heketi/
    state: directory
    mode: 0755

- name: copy heketi configuration
  copy:
    src: heketi-server.yml
    dest: "~/.kubernetes-yaml/heketi/heketi-server.yml"

- name: start heketi
  command: >
    kubectl apply -f
    $HOME/.kubernetes-yaml/heketi/heketi-server.yml

- name: wait for heketi to be Running
  command: >
    kubectl get pods --namespace=storage-heketi
    -o jsonpath='{.items[?(@.spec.containers[*].name=="heketi")].status.phase}'
  register: get_phase
  until: get_phase.stdout | match('^(Running\s)*Running$')
  # Wait for 10 minutes
  retries: 120
  delay: 5

- name: wait for heketi to be Ready
  command: >
    kubectl get pods --namespace=storage-heketi
    -o jsonpath='{.items[?(@.spec.containers[*].name=="heketi")].status.containerStatuses[*].ready}'
  register: get_is_ready
  until: get_is_ready.stdout | match( '^(true\s)*true$' )
  # Wait for 10 minutes
  retries: 120
  delay: 5

Add --overwrite param to node tainting to allow for applying command multiple times
Add --overwrite param to node tainting to allow for applying command multiple times
