main.yml 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ---
  2. # Ensures that the realm and a test client in it are created.
  3. - name: Check for the KeyCloak resource to see it shows ready state
  4. k8s_info:
  5. kubeconfig: tmp/kubeconfig-ocp4
  6. validate_certs: no
  7. api_version: keycloak.org/v1alpha1
  8. kind: keycloak
  9. namespace: rhsso
  10. name: rhsso
  11. register: sso_cr
  12. - assert:
  13. that:
  14. - (sso_cr.resources | length) == 1
  15. - sso_cr.resources[0].status.ready
  16. - sso_cr.resources[0].status.phase == "reconciling"
  17. fail_msg: "ERROR: RHSSO instance is missing or not configured correctly."
  18. success_msg: "OK: RHSSO instance is configured correctly."
  19. - name: Make sure the realm resource is correctly configured
  20. k8s:
  21. kubeconfig: tmp/kubeconfig-ocp4
  22. validate_certs: no
  23. api_version: keycloak.org/v1alpha1
  24. kind: keycloakrealm
  25. namespace: rhsso
  26. name: sample-realm
  27. definition:
  28. metadata:
  29. labels:
  30. app: sso
  31. realm: sample
  32. spec:
  33. instanceSelector:
  34. matchLabels:
  35. app: sso
  36. realm:
  37. id: sample
  38. realm: sample
  39. enabled: True
  40. displayName: "Sample Realm"
  41. tags:
  42. - realm
  43. - name: Wait for the realm resource to show ready state
  44. k8s_info:
  45. kubeconfig: tmp/kubeconfig-ocp4
  46. validate_certs: no
  47. api_version: keycloak.org/v1alpha1
  48. kind: keycloakrealm
  49. namespace: rhsso
  50. name: sample-realm
  51. register: sso_realm
  52. until:
  53. - (sso_realm.resources | length) == 1
  54. - sso_realm.resources[0].status is defined
  55. - sso_realm.resources[0].status.ready
  56. - sso_realm.resources[0].status.phase == "reconciling"
  57. retries: 30
  58. delay: 10
  59. - name: Also ensure there is a client in the sample realm
  60. k8s:
  61. kubeconfig: tmp/kubeconfig-ocp4
  62. validate_certs: no
  63. api_version: keycloak.org/v1alpha1
  64. kind: keycloakclient
  65. namespace: rhsso
  66. name: sample-client
  67. definition:
  68. metadata:
  69. labels:
  70. app: sso
  71. realm: sample
  72. client: sample
  73. spec:
  74. realmSelector:
  75. matchLabels:
  76. app: sso
  77. realm: sample
  78. client:
  79. clientId: sample-client
  80. defaultClientScopes:
  81. - email
  82. - offline_access
  83. - profile
  84. - roles
  85. protocolMappers:
  86. - name: groups
  87. protocol: openid-connect
  88. protocolMapper: oidc-usermodel-client-role-mapper
  89. consentRequired: false
  90. implicitFlowEnabled: False
  91. standardFlowEnabled: True
  92. redirectUris:
  93. - https://oauth-openshift.apps.ocp4.example.com/*
  94. tags:
  95. - client
  96. - name: Wait for the client resource to show ready state
  97. k8s_info:
  98. kubeconfig: tmp/kubeconfig-ocp4
  99. validate_certs: no
  100. api_version: keycloak.org/v1alpha1
  101. kind: keycloakclient
  102. namespace: rhsso
  103. name: sample-client
  104. register: sso_client
  105. until:
  106. - (sso_client.resources | length) == 1
  107. - sso_client.resources[0].status is defined
  108. - sso_client.resources[0].status.ready
  109. - sso_client.resources[0].status.phase == "reconciling"
  110. retries: 30
  111. delay: 10
  112. ...