ansible-middleware/keycloak

Wait until keycloak becomes active http://localhost:9990/health

ayoubch11 opened this issue · 6 comments

SUMMARY

i tried install keycklock with ha_mod but always i have a problem in this step : Wait until keycloak becomes active http://localhost:9990/health

STEPS TO REPRODUCE
- name: Playbook for Wildfly Hosts - Host 1
  hosts: keycloak
  collections:
    - middleware_automation.keycloak
  tasks:
    - name: Include keycloak role
      ansible.builtin.include_role:
        name: middleware_automation.keycloak.keycloak 
      vars:
        keycloak_ha_enabled: True
        keycloak_admin_user: "admin"
        keycloak_host: "kube1"
        keycloak_modcluster_url: 192.168.56.200
        keycloak_modcluster_enabled: "True"
EXPECTED RESULTS
ACTUAL RESULTS
[curl  -I http://localhost:9990/health
HTTP/1.1 503 Service Unavailable
Connection: keep-alive
Content-Type: application/json
Content-Length: 114364

Date: Mon, 19 Jun 2023 15:06:46 GMT](fatal: [192.168.56.72]: FAILED! => {"attempts": 25, "changed": false, "connection": "close", "content_length": "114364", "content_type": "application/json", "date": "Mon, 19 Jun 2023 15:05:15 GMT", "elapsed": 0, "msg": "Status code was 503 and not [200]: HTTP Error 503: Service Unavailable", "redirected": false, "status": 503, "url": "http://localhost:9990/health"})

Hello; you would need to provide the keycloak logs to see what happens, but just looking at our variables, I'd say it cannot connect to the database (ha requires a db).

The defaults for database configuration are here

I don't think the problem comes from the database, because the service is active and i don't have error
I have configured the database correctly.
● keycloak.service - keycloak Server
Loaded: loaded (/etc/systemd/system/keycloak.service; enabled; vendor preset: disabled)
Active: active (running) since lun. 2023-06-19 14:56:29 UTC; 23min ago
Process: 19863 ExecStop=/opt/keycloak/keycloak-service.sh stop (code=exited, status=0/SUCCESS)
Process: 21345 ExecStart=/opt/keycloak/keycloak-service.sh start (code=exited, status=0/SUCCESS)
Main PID: 21415 (java)
CGroup: /system.slice/keycloak.service
├─21348 /bin/sh /opt/keycloak/keycloak-19.0.3/bin/standalone.sh -Djboss.bind.address=0.0.0.0 -Djboss.http.port=8080 -Djboss.https.port=8443 -Djboss.management.http.port=9990 -Djboss.management.http...
└─21415 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.372.b07-1.el7_9.x86_64/jre/bin/java -D[Standalone] -server -Xms1024m -Xmx2048m -Dorg.jboss.boot.log.file=/opt/keycloak/keycloak-19.0.3/standalone/log/s...

juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,257 INFO [org.infinispan.CLUSTER] (thread-10,ejb,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=org.inf...topology id 4
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,258 INFO [org.infinispan.CLUSTER] (thread-13,ejb,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=org.inf...topology id 4
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,259 INFO [org.infinispan.CLUSTER] (thread-5,null,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=org.infinispan.CONFI...
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,270 INFO [org.infinispan.CLUSTER] (thread-5,null,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=org.infinispan.CONFI...
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,303 INFO [org.infinispan.CLUSTER] (thread-5,null,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=org.infinispan.CONFI...
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,330 INFO [org.infinispan.CLUSTER] (thread-5,null,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=http-remoting-connec...
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,574 INFO [org.infinispan.CLUSTER] (thread-13,ejb,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=http-re...topology id 3
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,579 INFO [org.infinispan.CLUSTER] (thread-13,ejb,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=http-re...topology id 4
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,600 INFO [org.infinispan.CLUSTER] (thread-13,ejb,192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null)) [Context=http-remoting-connec...
juin 19 15:00:59 kube1 keycloak-service.sh[21345]: 15:00:59,769 WARN [org.jboss.as.ejb3.remote] (ClusterTopologyRegistrar - 1) WFLYEJB0509: Clustered Jakarta Enterprise Beans in Node: 192.168.56.72 are bound.

Please provide the collection version used, the ansible-playbook execution output and the /opt/keycloak/...../standalone/log/server.log file to investigate the problem.

you find the file attached for server.log and the ansible-playbook execution output
server.log.txt
output.log

I see, it's the infinispan subsystem in keycloak looking for remote cache server (remote caches are enabled by default when keycloak_ha_enabled is True). If you have infinispan running on the same hosts, make sure it is up when keycloak starts; otherwise, if you want to use the embedded infinispan subsystem in keycloak, please add the variable keycloak_remote_cache_enabled: False

thank you for your response.
i have the same problem il the other node

2023-06-19 20:12:55,760 ERROR [org.infinispan.CLUSTER] (thread-37,ejb,192.168.56.72(site-id=192.168.56.72, rack-id=null, machine-id=null)) ISPN000474: Error processing request 44@192.168.56.71(site-id=192.168.56.71, rack-id=null, machine-id=null): java.lang.ClassNotFoundException: org.keycloak.cluster.infinispan.WrapperClusterEvent$ExternalizerImpl from [Module "org.wildfly.clustering.infinispan.spi" version 26.1.1.Final from local module loader @17c68925 (finder: local module finder @7e0ea639 (roots: /opt/keycloak/keycloak-19.0.3/modules,/opt/keycloak/keycloak-19.0.3/modules/system/layers/keycloak,/opt/keycloak/keycloak-19.0.3/modules/system/layers/base))]