--- - name: "Authenticate with Keycloak server" uri: url: "{{ keycloak_server_url }}/auth/realms/master/protocol/openid-connect/token" method: POST body_format: form-urlencoded body: 'username={{ keycloak_admin_username }}&password={{ keycloak_admin_password }}&client_id=admin-cli&grant_type=password' register: keycloak_authentication delegate_to: 127.0.0.1 retries: 5 delay: 5 - name: Save access_token as variable (fact) set_fact: access_token: "{{ keycloak_authentication.json.access_token }}" delegate_to: 127.0.0.1 - name: Print keycloak access_token debug: msg: "{{ access_token }}" delegate_to: 127.0.0.1