main.yml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---
  2. # Ensures the RHSSO instance (driven by a KeyCloak resource) is there.
  3. #
  4. - name: Check that the CSV is there and completed
  5. k8s_info:
  6. kubeconfig: tmp/kubeconfig-ocp4
  7. validate_certs: no
  8. api_version: operators.coreos.com/v1alpha1
  9. kind: clusterserviceversion
  10. namespace: rhsso
  11. name: rhsso-operator.7.6.0-opr-003
  12. register: sso_csv
  13. - assert:
  14. that:
  15. - sso_csv.resources is defined
  16. - (sso_csv.resources | length) == 1
  17. - sso_csv.resources[0].status.phase == "Succeeded"
  18. fail_msg: "ERROR: RHSSO operator not deployed or not registered correctly."
  19. success_msg: "OK: RHSSO operator deployed correctly."
  20. - name: Check for the presence of stray KeyCloak resources
  21. k8s_info:
  22. kubeconfig: tmp/kubeconfig-ocp4
  23. validate_certs: no
  24. api_version: keycloak.org/v1alpha1
  25. kind: keycloak
  26. namespace: rhsso
  27. register: sso_cr
  28. - assert:
  29. that:
  30. - (sso_cr.resources | length) == 1
  31. - sso_cr.resources[0].metadata.name == "rhsso"
  32. fail_msg: "ERROR: RHSSO instances other than the required one exist."
  33. success_msg: "OK: Required RHSSO instance exists."
  34. when:
  35. - sso_cr.resources is defined
  36. - (sso_cr.resources | length) > 0
  37. - name: Make sure there is a KeyCloak resource in the project
  38. k8s:
  39. kubeconfig: tmp/kubeconfig-ocp4
  40. validate_certs: no
  41. api_version: keycloak.org/v1alpha1
  42. kind: keycloak
  43. namespace: rhsso
  44. name: rhsso
  45. definition:
  46. metadata:
  47. labels:
  48. app: sso
  49. spec:
  50. instances: 1
  51. externalAccess:
  52. enabled: true
  53. - name: Wait for the KeyCloak resource to show ready state
  54. k8s_info:
  55. kubeconfig: tmp/kubeconfig-ocp4
  56. validate_certs: no
  57. api_version: keycloak.org/v1alpha1
  58. kind: keycloak
  59. namespace: rhsso
  60. name: rhsso
  61. register: sso_cr
  62. until:
  63. - (sso_cr.resources | length) == 1
  64. - sso_cr.resources[0].status.ready
  65. - sso_cr.resources[0].status.phase == "reconciling"
  66. retries: 30
  67. delay: 10
  68. - name: Show some basic information about the instance.
  69. pause:
  70. prompt: |-
  71. *******************************************************************************************************
  72. KeyCloak instance rhsso is now available at {{ sso_cr.resources[0].status.externalURL }}
  73. You can obtain the necessary credentials from secrets/{{ sso_cr.resources[0].status.credentialSecret }}
  74. *******************************************************************************************************
  75. seconds: 5
  76. ...