glusterfs_uninstall.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. - name: Delete pre-existing GlusterFS config
  50. file:
  51. path: /var/lib/glusterd
  52. state: absent
  53. delegate_to: "{{ item }}"
  54. with_items: "{{ glusterfs_nodes | default([]) }}"
  55. - name: Delete pre-existing additional GlusterFS config
  56. file:
  57. path: /etc/glusterfs
  58. state: absent
  59. delegate_to: "{{ item }}"
  60. with_items: "{{ glusterfs_nodes | default([]) }}"
  61. - name: Delete pre-existing Heketi config
  62. file:
  63. path: /var/lib/heketi
  64. state: absent
  65. delegate_to: "{{ item }}"
  66. with_items: "{{ glusterfs_nodes | default([]) }}"
  67. - name: Delete Glusterfs logs
  68. file:
  69. path: /var/log/glusterfs
  70. state: absent
  71. delegate_to: "{{ item }}"
  72. with_items: "{{ glusterfs_nodes | default([]) }}"
  73. - name: Delete deploy resources
  74. oc_obj:
  75. namespace: "{{ glusterfs_namespace }}"
  76. kind: "{{ item.kind }}"
  77. name: "{{ item.name | default(omit) }}"
  78. selector: "{{ item.selector | default(omit) }}"
  79. state: absent
  80. with_items:
  81. - kind: "template,route,service,jobs,dc,secret"
  82. selector: "deploy-heketi"
  83. - kind: "svc"
  84. name: "heketi-storage-endpoints"
  85. - kind: "secret"
  86. name: "heketi-{{ glusterfs_name }}-topology-secret"
  87. - name: Get GlusterFS storage devices state
  88. command: "pvdisplay -C --noheadings -o pv_name,vg_name {% for device in hostvars[item].glusterfs_devices %}{{ device }} {% endfor %}"
  89. register: devices_info
  90. delegate_to: "{{ item }}"
  91. with_items: "{{ glusterfs_nodes | default([]) }}"
  92. failed_when: False
  93. when: glusterfs_wipe
  94. # Runs "lvremove -ff <vg>; vgremove -fy <vg>; pvremove -fy <pv>" for every device found to be a physical volume.
  95. - name: Clear GlusterFS storage device contents
  96. shell: "{% for line in item.stdout_lines %}{% set fields = line.split() %}{% if fields | count > 1 %}lvremove -ff {{ fields[1] }}; vgremove -fy {{ fields[1] }}; {% endif %}pvremove -fy {{ fields[0] }}; {% endfor %}"
  97. delegate_to: "{{ item.item }}"
  98. with_items: "{{ devices_info.results }}"
  99. register: clear_devices
  100. until:
  101. - "'contains a filesystem in use' not in clear_devices.stderr"
  102. delay: 1
  103. retries: 30
  104. when:
  105. - glusterfs_wipe
  106. - item.stdout_lines | count > 0