delete_logging.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ---
  2. - name: stop logging
  3. include: stop_cluster.yaml
  4. # delete the deployment objects that we had created
  5. - name: delete logging api objects
  6. oc_obj:
  7. state: absent
  8. kind: "{{ item }}"
  9. namespace: "{{ openshift_logging_namespace }}"
  10. selector: "logging-infra"
  11. with_items:
  12. - dc
  13. - rc
  14. - svc
  15. - routes
  16. - templates
  17. - daemonset
  18. register: delete_result
  19. # delete the oauthclient
  20. - name: delete oauthclient kibana-proxy
  21. command: >
  22. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig delete oauthclient kibana-proxy --ignore-not-found=true
  23. register: delete_result
  24. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  25. # delete any image streams that we may have created
  26. - name: delete logging is
  27. command: >
  28. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  29. delete is -l logging-infra=support -n {{ openshift_logging_namespace }} --ignore-not-found=true
  30. register: delete_result
  31. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  32. # delete our old secrets
  33. - name: delete logging secrets
  34. command: >
  35. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  36. delete secret {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  37. with_items:
  38. - logging-fluentd
  39. - logging-elasticsearch
  40. - logging-kibana
  41. - logging-kibana-proxy
  42. - logging-curator
  43. - logging-mux
  44. ignore_errors: yes
  45. register: delete_result
  46. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  47. # delete role bindings
  48. - name: delete rolebindings
  49. command: >
  50. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  51. delete rolebinding {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  52. with_items:
  53. - logging-elasticsearch-view-role
  54. register: delete_result
  55. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  56. # delete cluster role bindings
  57. - name: delete cluster role bindings
  58. command: >
  59. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  60. delete clusterrolebindings {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  61. with_items:
  62. - rolebinding-reader
  63. register: delete_result
  64. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  65. # delete cluster roles
  66. - name: delete cluster roles
  67. command: >
  68. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  69. delete clusterroles {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  70. with_items:
  71. - rolebinding-reader
  72. register: delete_result
  73. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  74. # delete our service accounts
  75. - name: delete service accounts
  76. oc_serviceaccount:
  77. name: "{{ item }}"
  78. namespace: "{{ openshift_logging_namespace }}"
  79. state: absent
  80. with_items:
  81. - aggregated-logging-elasticsearch
  82. - aggregated-logging-kibana
  83. - aggregated-logging-curator
  84. - aggregated-logging-fluentd
  85. # delete our roles
  86. - name: delete roles
  87. command: >
  88. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  89. delete clusterrole {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  90. with_items:
  91. - daemonset-admin
  92. register: delete_result
  93. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0
  94. # delete our configmaps
  95. - name: delete configmaps
  96. command: >
  97. {{ openshift.common.client_binary }} --config={{ mktemp.stdout }}/admin.kubeconfig
  98. delete configmap {{ item }} -n {{ openshift_logging_namespace }} --ignore-not-found=true
  99. with_items:
  100. - logging-curator
  101. - logging-elasticsearch
  102. - logging-fluentd
  103. - logging-mux
  104. register: delete_result
  105. changed_when: delete_result.stdout.find("deleted") != -1 and delete_result.rc == 0