glusterblock_deploy.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---
  2. - name: Delete pre-existing glusterblock provisioner resources
  3. oc_obj:
  4. namespace: "{{ glusterfs_namespace }}"
  5. kind: "{{ item.kind }}"
  6. name: "{{ item.name | default(omit) }}"
  7. selector: "{{ item.selector | default(omit) }}"
  8. state: absent
  9. with_items:
  10. - kind: "all,deploy,sa,clusterrole,clusterrolebinding"
  11. selector: "glusterblock"
  12. failed_when: False
  13. when: glusterfs_wipe
  14. - name: Wait for glusterblock provisioner pods to terminate
  15. oc_obj:
  16. namespace: "{{ glusterfs_namespace }}"
  17. kind: pod
  18. state: list
  19. selector: "glusterfs=block-{{ glusterfs_name }}-provisioner-pod"
  20. register: glusterblock_pod
  21. until: "glusterblock_pod.results.results[0]['items'] | count == 0"
  22. delay: 10
  23. retries: "{{ (glusterfs_timeout | int / 10) | int }}"
  24. when: glusterfs_wipe
  25. - name: Copy initial glusterblock provisioner resource file
  26. copy:
  27. src: "{{ item }}"
  28. dest: "{{ mktemp.stdout }}/{{ item }}"
  29. with_items:
  30. - "glusterblock-provisioner.yml"
  31. - name: Create glusterblock provisioner template
  32. oc_obj:
  33. namespace: "{{ glusterfs_namespace }}"
  34. kind: template
  35. name: "glusterblock-provisioner"
  36. state: present
  37. files:
  38. - "{{ mktemp.stdout }}/glusterblock-provisioner.yml"
  39. - name: Deploy glusterblock provisioner
  40. oc_process:
  41. namespace: "{{ glusterfs_namespace }}"
  42. template_name: "glusterblock-provisioner"
  43. create: True
  44. params:
  45. IMAGE_NAME: "{{ glusterfs_block_image }}"
  46. NAMESPACE: "{{ glusterfs_namespace }}"
  47. CLUSTER_NAME: "{{ glusterfs_name }}"
  48. - name: Wait for glusterblock provisioner pod
  49. oc_obj:
  50. namespace: "{{ glusterfs_namespace }}"
  51. kind: pod
  52. state: list
  53. selector: "glusterfs=block-{{ glusterfs_name }}-provisioner-pod"
  54. register: glusterblock_pod
  55. until:
  56. - "glusterblock_pod.results.results[0]['items'] | count > 0"
  57. # Pod's 'Ready' status must be True
  58. - "glusterblock_pod.results.results[0]['items'] | lib_utils_oo_collect(attribute='status.conditions') | lib_utils_oo_collect(attribute='status', filters={'type': 'Ready'}) | map('bool') | select | list | count == 1"
  59. delay: 10
  60. retries: "{{ (glusterfs_timeout | int / 10) | int }}"