main.yml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # 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. ...