main.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ---
  2. # Ensures all the operator artifacts are created and waits for CSV to succeed.
  3. #
  4. # NOTE: Do NOT test by checking for presence of API resources in the
  5. # keycloak.org API group. They do not always get cleaned up.
  6. #
  7. - name: Check if the RHSSO CSV exists already
  8. k8s_info:
  9. kubeconfig: tmp/kubeconfig-ocp4
  10. validate_certs: no
  11. api_version: operators.coreos.com/v1alpha1
  12. kind: clusterserviceversion
  13. register: all_csv
  14. - name: Find RHSSO CSV among all CSVs
  15. set_fact:
  16. rhsso_csv: "{{ (all_csv | community.general.json_query(\"resources[?metadata.name == 'rhsso-operator.7.6.0-opr-003']\")) }}"
  17. when:
  18. - all_csv.resources is defined
  19. - (all_csv.resources | length) > 0
  20. - name: Get details about RHSSO CSV if found
  21. set_fact:
  22. rhsso_csv_ns: "{{ rhsso_csv[0] | community.general.json_query('metadata.namespace') }}"
  23. rhsso_csv_name: "{{ rhsso_csv[0] | community.general.json_query('metadata.name') }}"
  24. when:
  25. - rhsso_csv is defined
  26. - (rhsso_csv | length) > 0
  27. - assert:
  28. that:
  29. - ((rhsso_csv_ns | default("")) == "") or ((rhsso_csv_ns | default("")) == "rhsso")
  30. - ((rhsso_csv_name | default("")) == "") or ((rhsso_csv_name | default("")) == "rhsso-operator.7.6.0-opr-003")
  31. fail_msg: "ERROR: RHSSO CSV already present in {{ rhsso_csv_ns | default('NA') }}/{{ rhsso_csv_name | default('NA') }} - please remove manually!"
  32. success_msg: "OK: RHSSO CSV not present or configured correctly."
  33. - name: Make sure the namespace is there
  34. k8s:
  35. kubeconfig: tmp/kubeconfig-ocp4
  36. validate_certs: no
  37. api_version: v1
  38. kind: namespace
  39. name: rhsso
  40. - name: Make sure it has a properly configured OperatorGroup
  41. k8s:
  42. kubeconfig: tmp/kubeconfig-ocp4
  43. validate_certs: no
  44. api_version: operators.coreos.com/v1
  45. kind: operatorgroup
  46. namespace: rhsso
  47. name: rhsso-operator-group
  48. definition:
  49. spec:
  50. targetNamespaces:
  51. - rhsso
  52. - name: Also make sure there is a subscription
  53. k8s:
  54. kubeconfig: tmp/kubeconfig-ocp4
  55. validate_certs: no
  56. api_version: operators.coreos.com/v1alpha1
  57. kind: subscription
  58. namespace: rhsso
  59. name: rhsso-subscription
  60. definition:
  61. spec:
  62. source: do280-sso
  63. sourceNamespace: openshift-marketplace
  64. name: rhsso-operator
  65. channel: stable
  66. installPlanApproval: Automatic
  67. - name: Wait for installPlan to show up
  68. k8s_info:
  69. kubeconfig: tmp/kubeconfig-ocp4
  70. validate_certs: no
  71. api_version: operators.coreos.com/v1alpha1
  72. kind: installplan
  73. namespace: rhsso
  74. register: sso_ip
  75. until:
  76. - sso_ip.resources is defined
  77. - (sso_ip.resources | length) > 0
  78. - sso_ip.resources[0].spec.approved
  79. retries: 12
  80. delay: 10
  81. - name: Wait for CSV to show up and complete
  82. k8s_info:
  83. kubeconfig: tmp/kubeconfig-ocp4
  84. validate_certs: no
  85. api_version: operators.coreos.com/v1alpha1
  86. kind: clusterserviceversion
  87. namespace: rhsso
  88. register: sso_csv
  89. until:
  90. - sso_csv.resources is defined
  91. - (sso_csv.resources | length) > 0
  92. - sso_csv.resources[0].status.phase == "Succeeded"
  93. retries: 30
  94. delay: 10
  95. - name: Finally, wait for the pod
  96. k8s_info:
  97. kubeconfig: tmp/kubeconfig-ocp4
  98. validate_certs: no
  99. api_version: v1
  100. kind: pod
  101. namespace: rhsso
  102. label_selectors:
  103. - name = rhsso-operator
  104. register: sso_pod
  105. until:
  106. - sso_pod.resources is defined
  107. - (sso_pod.resources | length) > 0
  108. - sso_pod.resources[0].status.phase == "Running"
  109. retries: 30
  110. delay: 10
  111. ...