main.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---
  2. # Ensures all the operator artifacts are created and waits for CSV to succeed.
  3. #
  4. # The following variables must exist:
  5. #
  6. # removed_operators: a list of below dictionaries
  7. # - sub_nspc subscription namespace
  8. # sub_name subscription name
  9. # csv_name CSV name to check for
  10. # pre_cleanup pre-cleanup tasks, a list of rtypes to remove (ALL)
  11. # - apiv
  12. # kind
  13. # add_cleanup additional CRDs to remove post-uninstall, a list
  14. #
  15. # This role must then be applied as:
  16. #
  17. # - include_role:
  18. # name: remove-operators
  19. # loop: "{{ removed_operators }}"
  20. # loop_control:
  21. # loop_var: role
  22. #
  23. # What this means is that each item of removed_operators is expected to be
  24. # placed in the "role" variable prior to iterating over this role.
  25. #
  26. - name: Remove any of the resources found
  27. k8s:
  28. kubeconfig: tmp/kubeconfig-ocp4
  29. validate_certs: no
  30. api_version: "{{ item.apiv }}"
  31. kind: "{{ item.kind }}"
  32. delete_all: true
  33. state: absent
  34. ignore_errors: yes
  35. loop: "{{ role.pre_cleanup }}"
  36. register: removed
  37. - name: Remove the subscription
  38. k8s:
  39. kubeconfig: tmp/kubeconfig-ocp4
  40. validate_certs: no
  41. api_version: operators.coreos.com/v1alpha1
  42. kind: subscription
  43. name: "{{ role.sub_name }}"
  44. namespace: "{{ role.sub_nspc }}"
  45. state: absent
  46. ignore_errors: yes
  47. - name: Do post-cleanup
  48. k8s:
  49. kubeconfig: tmp/kubeconfig-ocp4
  50. validate_certs: no
  51. api_version: apiextensions.k8s.io/v1
  52. kind: customresourcedefinition
  53. name: "{{ item }}"
  54. state: absent
  55. ignore_errors: yes
  56. loop: "{{ role.add_cleanup }}"
  57. - name: Remove the CSV as well, if so required
  58. k8s:
  59. kubeconfig: tmp/kubeconfig-ocp4
  60. validate_certs: no
  61. api_version: operators.coreos.com/v1alpha1
  62. kind: clusterserviceversion
  63. name: "{{ role.csv_name }}"
  64. namespace: "{{ role.sub_nspc }}"
  65. state: absent
  66. ignore_errors: yes
  67. when: role.csv_kill
  68. - name: Lastly, remove the namespace, if instructed
  69. k8s:
  70. kubeconfig: tmp/kubeconfig-ocp4
  71. validate_certs: no
  72. api_version: v1
  73. kind: namespace
  74. name: "{{ role.sub_nspc }}"
  75. state: absent
  76. ignore_errors: yes
  77. when: role.nsp_kill
  78. ...