main.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 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. # vars:
  20. # - role: "{{ item }}"
  21. # loop: "{{ removed_operators }}"
  22. #
  23. - name: Remove any of the resources found
  24. k8s:
  25. kubeconfig: tmp/kubeconfig-ocp4
  26. validate_certs: no
  27. api_version: "{{ item.apiv }}"
  28. kind: "{{ item.kind }}"
  29. delete_all: true
  30. state: absent
  31. ignore_errors: yes
  32. loop: "{{ role.pre_cleanup }}"
  33. register: removed
  34. - name: Remove the subscription
  35. k8s:
  36. kubeconfig: tmp/kubeconfig-ocp4
  37. validate_certs: no
  38. api_version: operators.coreos.com/v1alpha1
  39. kind: subscription
  40. name: "{{ role.sub_name }}"
  41. namespace: "{{ role.sub_nspc }}"
  42. state: absent
  43. ignore_errors: yes
  44. - name: Do post-cleanup
  45. k8s:
  46. kubeconfig: tmp/kubeconfig-ocp4
  47. validate_certs: no
  48. api_version: apiextensions.k8s.io/v1
  49. kind: customresourcedefinition
  50. name: "{{ item }}"
  51. state: absent
  52. ignore_errors: yes
  53. loop: "{{ role.add_cleanup }}"
  54. - name: Remove the CSV as well, if so required
  55. k8s:
  56. kubeconfig: tmp/kubeconfig-ocp4
  57. validate_certs: no
  58. api_version: operators.coreos.com/v1alpha1
  59. kind: clusterserviceversion
  60. name: "{{ role.csv_name }}"
  61. delete_all: true
  62. state: absent
  63. ignore_errors: yes
  64. when: csv_kill
  65. ...