I’m in the process of configure KeycloakOIDC as authentication provider via Ansible using the API, but when I try to send the POST to testAndApply, it requires an authorization code I cannot retrieve without a browser.
Is there anyway to fully configure KeycloakOIDC via API?
- name: Configure Keycloak Authentication
ansible.builtin.uri:
url: "https://{{ ansible_fqdn }}/v3/keyCloakOIDCConfigs/keycloakoidc?action=configureTest"
method: POST
headers:
Authorization: "Bearer {{ rancher_api_token }}"
Content-Type: "application/json"
body:
accessMode: "unrestricted"
enabled: true
type: "keyCloakOIDCConfig"
uuid: "fe651219-adbc-427a-bf1f-ac1f8257fce1"
clientId: "rancher"
clientSecret: "QzkGBXod9B6LSbRdFH5HT6dr7b0FPyIT"
authEndpoint: "https://test-1:8443/realms/master/protocol/openid-connect/auth"
tokenEndpoint: "https://test-1:8443/realms/master/protocol/openid-connect/token"
issuer: "https://test-1:8443/realms/master"
rancherUrl: "https://rancher.test.gi/verify-auth"
scope: "openid profile email"
body_format: json
validate_certs: no
register: response
- name: Enable Keycloak
ansible.builtin.uri:
url: "https://{{ ansible_fqdn }}/v3/keyCloakOIDCConfigs/keycloakoidc?action=testAndApply"
method: POST
headers:
Authorization: "Bearer {{ rancher_api_token }}"
Content-Type: "application/json"
body_format: json
body:
code: "{{ THIS IS THE MISSING CODE }}"
enabled: true
oidcConfig:
tokenEndpoint: "https://test-1:8443/realms/master/protocol/openid-connect/token"
accessMode: "unrestricted"
groupSearchEnabled: true
groupsClaim: "groups"
enabled: true
baseType: "authConfig"
type: "keyCloakOIDCConfig"
logoutAllSupported: false
rancherUrl: "https://rancher.test.gi/verify-auth"
id: "keycloakoidc"
clientId: "rancher"
uuid: "fe651219-adbc-427a-bf1f-ac1f8257fce1"
clientSecret: "QzkGBXod9B6LSbRdFH5HT6dr7b0FPyIT"
scope: "openid profile email"
authEndpoint: "https:/test-1:8443/realms/master/protocol/openid-connect/auth"
issuer: "https://test-1:8443/realms/master"
validate_certs: no
register: response