main.yml 3.6 KB

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