mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-12-10 11:26:24 +00:00
This commit updates multiple roles to ensure compatibility with Ansible 2.20. Several include paths and task-loading mechanisms required adjustments, as Ansible 2.20 applies stricter evaluation rules for complex Jinja expressions and no longer resolves certain relative include paths the way Ansible 2.18 did. Key changes: - Replaced legacy once_finalize.yml and once_flag.yml with the new structure under tasks/utils/once/finalize.yml and tasks/utils/once/flag.yml. - Updated all include_tasks statements to use 'path_join' with playbook_dir, ensuring deterministic and absolute file resolution across roles. - Fixed all network helper includes by converting direct relative paths such as 'roles/docker-compose/tasks/utils/network.yml' to proper Jinja-evaluated paths. - Normalized MATOMO_* variable names for consistency with the updated variable scope behavior in Ansible 2.20. - Removed deprecated patterns that were implicitly supported in Ansible 2.18 but break under the more strict variable and path resolution model in 2.20. These changes are part of the full migration step required to ensure the infinito-nexus roles remain stable, deterministic, and forward-compatible with Ansible 2.20. Details of the discussion and reasoning can be found in this conversation: https://chatgpt.com/share/69300a8d-24d4-800f-bec0-e895a695618a
60 lines
3.0 KiB
YAML
60 lines
3.0 KiB
YAML
---
|
||
|
||
- name: Check if OIDC plugin is present in container
|
||
command: >
|
||
docker exec --user root {{ MOODLE_CONTAINER }} test -d {{ BITNAMI_OIDC_PLUGIN_DIR }}
|
||
register: oidc_plugin_check
|
||
ignore_errors: true
|
||
changed_when: false
|
||
|
||
- name: Fail if plugin not present to avoid broken auth
|
||
fail:
|
||
msg: "OIDC plugin not present – skipping configuration"
|
||
when: oidc_plugin_check.rc != 0
|
||
|
||
#- name: "Upgrade Moodle to apply OIDC plugin"
|
||
# command: "docker exec --user {{ BITNAMI_USER }} {{ MOODLE_CONTAINER }} php /opt/bitnami/moodle/admin/cli/upgrade.php --non-interactive"
|
||
#
|
||
#- name: Clear Moodle cache
|
||
# command: >
|
||
# docker exec --user {{ BITNAMI_USER }} {{ MOODLE_CONTAINER }} php /opt/bitnami/moodle/admin/cli/purge_caches.php
|
||
|
||
- name: "Set Moodle OIDC configuration via CLI"
|
||
loop:
|
||
- { name: "idptype", value: 3 }
|
||
- { name: "clientauthmethod", value: 1 }
|
||
- { name: "clientid", value: "{{ OIDC.CLIENT.ID }}" }
|
||
- { name: "clientsecret", value: "{{ OIDC.CLIENT.SECRET }}" }
|
||
- { name: "opname", value: "{{ OIDC.BUTTON_TEXT }}" }
|
||
- { name: "oidcscope", value: "openid profile email" }
|
||
- { name: "authendpoint", value: "{{ OIDC.CLIENT.AUTHORIZE_URL }}" }
|
||
- { name: "tokenendpoint", value: "{{ OIDC.CLIENT.TOKEN_URL }}" }
|
||
- { name: "bindingusernameclaim", value: "{{ OIDC.ATTRIBUTES.USERNAME }}" }
|
||
- { name: "single_sign_off", value: 1 } # Logs the user out from the IDP
|
||
- { name: "logouturi", value: "{{ OIDC.CLIENT.LOGOUT_URL }}" }
|
||
- { name: "icon", value: "moodle:t/lock" }
|
||
- { name: "field_map_firstname", value: "{{ OIDC.ATTRIBUTES.GIVEN_NAME }}" }
|
||
- { name: "field_lock_firstname", value: "locked" }
|
||
- { name: "field_map_lastname", value: "{{ OIDC.ATTRIBUTES.FAMILY_NAME }}" }
|
||
- { name: "field_lock_lastname", value: "locked" }
|
||
- { name: "field_map_email", value: "locked" }
|
||
#- { name: "showloginform", value: 0 } # Deactivate if OIDC is active
|
||
- { name: "alternateloginurl", value: "{{ domains | get_url(application_id, WEB_PROTOCOL) }}/auth/oidc/" }
|
||
loop_control:
|
||
label: "{{ item.name }}"
|
||
command: >
|
||
docker exec --user {{ BITNAMI_USER }} {{ MOODLE_CONTAINER }} php /opt/bitnami/moodle/admin/cli/cfg.php --component=auth_oidc
|
||
--name={{ item.name }} --set="{{ item.value }}"
|
||
|
||
- name: "Enable OIDC login"
|
||
command: "docker exec --user {{ BITNAMI_USER }} {{ MOODLE_CONTAINER }} php /opt/bitnami/moodle/admin/cli/cfg.php --name=auth --set=oidc"
|
||
|
||
- name: Set auth = 'oidc' for all users except guest
|
||
shell: >
|
||
docker exec {{ database_instance }} mariadb -u {{ database_username }} -p{{ database_password }}
|
||
-e "UPDATE moodle.mdl_user SET auth = 'oidc' WHERE username != 'guest';"
|
||
args:
|
||
executable: /bin/bash
|
||
|
||
#- name: Prevent Account Creation
|
||
# command: docker exec --user {{ BITNAMI_USER }} {{ MOODLE_CONTAINER }} php /opt/bitnami/moodle/admin/cli/cfg.php --name=authpreventaccountcreation --set=1 |