glusterfs_uninstall.yml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ---
  2. - name: Delete pre-existing heketi 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: "template,route,service,dc,jobs,secret"
  11. selector: "deploy-heketi"
  12. - kind: "svc"
  13. name: "heketi-storage-endpoints"
  14. - kind: "svc"
  15. name: "heketi-storage"
  16. - kind: "secret"
  17. name: "heketi-{{ glusterfs_name }}-topology-secret"
  18. - kind: "template,route,service,dc"
  19. name: "heketi-{{ glusterfs_name }}"
  20. - kind: "svc"
  21. name: "heketi-db-{{ glusterfs_name }}-endpoints"
  22. - kind: "sa"
  23. name: "heketi-{{ glusterfs_name }}-service-account"
  24. - kind: "secret"
  25. name: "heketi-{{ glusterfs_name }}-admin-secret"
  26. - kind: "secret"
  27. name: "heketi-{{ glusterfs_name }}-config-secret"
  28. failed_when: False
  29. - name: Delete pre-existing GlusterFS resources
  30. oc_obj:
  31. namespace: "{{ glusterfs_namespace }}"
  32. kind: "{{ item.kind }}"
  33. name: "{{ item.name }}"
  34. state: absent
  35. with_items:
  36. - kind: template
  37. name: glusterfs
  38. - kind: daemonset
  39. name: "glusterfs-{{ glusterfs_name }}"
  40. - kind: storageclass
  41. name: "glusterfs-{{ glusterfs_name }}"
  42. - name: Unlabel any existing GlusterFS nodes
  43. oc_label:
  44. name: "{{ hostvars[item].openshift.node.nodename }}"
  45. kind: node
  46. state: absent
  47. labels: "{{ glusterfs_nodeselector | lib_utils_oo_dict_to_list_of_dict }}"
  48. with_items: "{{ groups.all }}"
  49. when: "'openshift' in hostvars[item]"
  50. - name: Delete pre-existing GlusterFS config
  51. file:
  52. path: /var/lib/glusterd
  53. state: absent
  54. delegate_to: "{{ item }}"
  55. with_items: "{{ glusterfs_nodes | default([]) }}"
  56. - name: Delete pre-existing additional GlusterFS config
  57. file:
  58. path: /etc/glusterfs
  59. state: absent
  60. delegate_to: "{{ item }}"
  61. with_items: "{{ glusterfs_nodes | default([]) }}"
  62. - name: Delete pre-existing Heketi config
  63. file:
  64. path: /var/lib/heketi
  65. state: absent
  66. delegate_to: "{{ item }}"
  67. with_items: "{{ glusterfs_nodes | default([]) }}"
  68. - name: Delete Glusterfs logs
  69. file:
  70. path: /var/log/glusterfs
  71. state: absent
  72. delegate_to: "{{ item }}"
  73. with_items: "{{ glusterfs_nodes | default([]) }}"
  74. - name: Delete deploy resources
  75. oc_obj:
  76. namespace: "{{ glusterfs_namespace }}"
  77. kind: "{{ item.kind }}"
  78. name: "{{ item.name | default(omit) }}"
  79. selector: "{{ item.selector | default(omit) }}"
  80. state: absent
  81. with_items:
  82. - kind: "template,route,service,jobs,dc,secret"
  83. selector: "deploy-heketi"
  84. - kind: "svc"
  85. name: "heketi-storage-endpoints"
  86. - kind: "secret"
  87. name: "heketi-{{ glusterfs_name }}-topology-secret"
  88. - name: Delete glusterblock provisioner resources
  89. oc_obj:
  90. namespace: "{{ glusterfs_namespace }}"
  91. kind: "{{ item.kind }}"
  92. name: "{{ item.name | default(omit) }}"
  93. selector: "{{ item.selector | default(omit) }}"
  94. state: absent
  95. with_items:
  96. - kind: "all,deploy,sa,clusterrole,clusterrolebinding"
  97. selector: "glusterblock"
  98. failed_when: False
  99. - name: Delete gluster-s3 resources
  100. oc_obj:
  101. namespace: "{{ glusterfs_namespace }}"
  102. kind: "{{ item.kind }}"
  103. name: "{{ item.name | default(omit) }}"
  104. selector: "{{ item.selector | default(omit) }}"
  105. state: absent
  106. with_items:
  107. - kind: "all,svc,deploy,secret,sc,pvc"
  108. selector: "gluster-s3"
  109. failed_when: False
  110. - name: Get GlusterFS storage devices state
  111. command: "pvdisplay -C --noheadings -o pv_name,vg_name {% for device in hostvars[item].glusterfs_devices %}{{ device }} {% endfor %}"
  112. register: devices_info
  113. delegate_to: "{{ item }}"
  114. with_items: "{{ glusterfs_nodes | default([]) }}"
  115. failed_when: False
  116. when: glusterfs_wipe
  117. # Runs "lvremove -ff <vg>; vgremove -fy <vg>; pvremove -fy <pv>" for every device found to be a physical volume.
  118. - name: Clear GlusterFS storage device contents
  119. shell: "{% for line in item.stdout_lines %}{% set fields = line.split() %}{% if fields | count > 1 %}lvremove -ff {{ fields[1] }}; vgchange -an {{ fields[1] }}; vgremove -fy {{ fields[1] }}; dmsetup remove {{ fields[1] }}; {% endif %}pvremove -fy {{ fields[0] }}; {% endfor %}"
  120. delegate_to: "{{ item.item }}"
  121. with_items: "{{ devices_info.results }}"
  122. register: clear_devices
  123. until:
  124. - "'contains a filesystem in use' not in clear_devices.stderr"
  125. delay: 1
  126. retries: 30
  127. when:
  128. - glusterfs_wipe
  129. - item.stdout_lines | count > 0
  130. - name: Wipe filesystem signatures from storage devices
  131. command: "wipefs -a {% for device in hostvars[item].glusterfs_devices %}{{ device }} {% endfor %}"
  132. delegate_to: "{{ item }}"
  133. with_items: "{{ glusterfs_nodes | default([]) }}"
  134. failed_when: False
  135. when: glusterfs_wipe