-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix documentation, add variable checks, re-organise IAM-related tasks --------- Co-authored-by: gioacchino.vino <[email protected]>
- Loading branch information
Showing
4 changed files
with
89 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
- name: Retrieve registration endpoint from OpenID configuration | ||
uri: | ||
url: "{{ iam_url }}/.well-known/openid-configuration" | ||
method: GET | ||
return_content: yes | ||
register: openid_config | ||
- name: Set registration endpoint variable | ||
set_fact: | ||
registration_endpoint: "{{ openid_config.json.registration_endpoint }}" | ||
|
||
- name: Retrieve the IAM client info | ||
uri: | ||
url: "{{ registration_endpoint }}/{{ iam_client_id }}" | ||
method: GET | ||
headers: | ||
Authorization: "Bearer {{ iam_token }}" | ||
status_code: 200 | ||
return_content: yes | ||
register: iam_client_get_response | ||
|
||
- name: Save the IAM Client info locally | ||
ansible.builtin.copy: | ||
content: "{{ iam_client_get_response.json | to_nice_json }}" | ||
dest: /usr/local/share/dodasts/jupyterhub/cookies/.client-iam.json | ||
|
||
- name: Define the new redirect_uri variable | ||
ansible.builtin.set_fact: | ||
redirect_uri: "https://{{ dns_name }}:{{ jupyter_port }}/hub/oauth_callback" | ||
|
||
- name: Import the local IAM Client info file | ||
ansible.builtin.set_fact: | ||
iam_client_info: "{{ lookup('file', '/usr/local/share/dodasts/jupyterhub/cookies/.client-iam.json') }}" | ||
|
||
- name: Update the redirect_uris field | ||
ansible.builtin.set_fact: | ||
updated_iam_client_info: "{{ iam_client_info | combine({'redirect_uris': [redirect_uri]}) }}" | ||
|
||
- name: Save the updated IAM Client info locally | ||
ansible.builtin.copy: | ||
content: "{{ updated_iam_client_info | to_json }}" | ||
dest: /tmp/updated-iam-client.json | ||
|
||
- name: Import the local updated IAM Client info file | ||
ansible.builtin.slurp: | ||
src: /tmp/updated-iam-client.json | ||
register: iam_client_file | ||
|
||
- name: Update the IAM client info remotely | ||
uri: | ||
url: "{{ registration_endpoint }}/{{ iam_client_id }}" | ||
method: PUT | ||
headers: | ||
Authorization: "Bearer {{ iam_token }}" | ||
Content-Type: application/json | ||
body_format: json | ||
body: "{{ iam_client_file.content | b64decode | from_json }}" | ||
status_code: 200 | ||
register: iam_response | ||
|
||
- name: Delete local IAM Client info file | ||
ansible.builtin.file: | ||
path: /tmp/updated-iam-client.json | ||
state: absent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters