main.yml 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. loop: "{{ role.pre_cleanup }}"
  32. register: removed
  33. - name: Remove the subscription
  34. k8s:
  35. kubeconfig: tmp/kubeconfig-ocp4
  36. validate_certs: no
  37. api_version: operators.coreos.com/v1
  38. kind: subscription
  39. name: "{{ role.sub_name }}"
  40. namespace: "{{ role.sub_nspc }}"
  41. state: absent
  42. - name: Do post-cleanup
  43. k8s:
  44. kubeconfig: tmp/kubeconfig-ocp4
  45. validate_certs: no
  46. api_version: apiextensions.k8s.io/v1
  47. kind: customresourcedefinition
  48. name: "{{ item }}"
  49. state: absent
  50. loop: "{{ role.add_cleanup }}"
  51. ...