mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-11-06 05:08:16 +00:00
- Switched Drupal base image to PHP 8.2 for compatibility with openid_connect 2.x - Added mariadb-client to container to allow Drush to drop tables - Upgraded OIDC module from ^1 to ^2@beta for entity-based client configuration - Replaced legacy client creation task with generic plugin-based entity creation - Ensured /usr/local/bin is in PATH for www-data user - Updated oidc.yml to explicitly use the generic plugin References: https://chatgpt.com/share/6905cecc-8e3c-800f-849b-4041b6925381
80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
- name: "Load OIDC vars"
|
|
include_vars:
|
|
file: "{{ role_path }}/vars/oidc.yml"
|
|
name: oidc_vars
|
|
|
|
- name: "Apply openid_connect.settings (global)"
|
|
loop: "{{ oidc_vars.oidc_settings | dict2items }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
command: >
|
|
docker exec {{ DRUPAL_CONTAINER }} bash -lc
|
|
"drush -r {{ DRUPAL_DOCKER_HTML_PATH }} cset -y
|
|
openid_connect.settings {{ item.key }}
|
|
{{ (item.value | to_json) if item.value is mapping or item.value is sequence else item.value }}"
|
|
|
|
- name: "Ensure/Update OIDC client entity (generic)"
|
|
vars:
|
|
client_id: "{{ oidc_vars.oidc_client.id }}"
|
|
client_label: "{{ oidc_vars.oidc_client.label }}"
|
|
plugin_id: "{{ oidc_vars.oidc_client.plugin }}"
|
|
settings_b64: "{{ oidc_vars.oidc_client.settings | to_json | b64encode }}"
|
|
command: >
|
|
docker exec {{ DRUPAL_CONTAINER }} bash -lc
|
|
"drush -r {{ DRUPAL_DOCKER_HTML_PATH }} eval '
|
|
$id=\"{{ client_id }}\";
|
|
$label=\"{{ client_label }}\";
|
|
$plugin=\"{{ plugin_id }}\";
|
|
$settings=json_decode(base64_decode(\"{{ settings_b64 }}\"), TRUE);
|
|
$storage=\\Drupal::entityTypeManager()->getStorage(\"openid_connect_client\");
|
|
$e=$storage->load($id);
|
|
if (!$e) {
|
|
$e=$storage->create([
|
|
\"id\"=> $id,
|
|
\"label\"=> $label,
|
|
\"status\"=> TRUE,
|
|
\"plugin\"=> $plugin,
|
|
\"settings\"=> $settings,
|
|
]);
|
|
$e->save();
|
|
print \"created\";
|
|
} else {
|
|
$e->set(\"label\", $label);
|
|
$e->set(\"plugin\", $plugin);
|
|
$e->set(\"settings\", $settings);
|
|
$e->set(\"status\", TRUE);
|
|
$e->save();
|
|
print \"updated\";
|
|
}
|
|
'"
|
|
register: client_apply
|
|
changed_when: "'created' in client_apply.stdout or 'updated' in client_apply.stdout"
|
|
|
|
- name: "Apply OIDC client settings"
|
|
vars:
|
|
client_id: "{{ oidc_vars.oidc_client.id }}"
|
|
settings_map: "{{ oidc_vars.oidc_client.settings }}"
|
|
kv: "{{ settings_map | dict2items }}"
|
|
loop: "{{ kv }}"
|
|
loop_control:
|
|
label: "{{ item.key }}"
|
|
command: >
|
|
docker exec {{ DRUPAL_CONTAINER }} bash -lc
|
|
"drush -r {{ DRUPAL_DOCKER_HTML_PATH }} eval '
|
|
$id=\"{{ client_id }}\";
|
|
$key=\"{{ item.key }}\";
|
|
$val=json_decode(base64_decode(\"{{ (item.value | to_json | b64encode) }}\"), true);
|
|
$storage=\Drupal::entityTypeManager()->getStorage(\"openid_connect_client\");
|
|
$c=$storage->load($id);
|
|
$s=$c->get(\"settings\");
|
|
$s[$key]=$val;
|
|
$c->set(\"settings\", $s);
|
|
$c->save();'"
|
|
changed_when: true
|
|
|
|
- name: "Clear caches after OIDC config"
|
|
command: >
|
|
docker exec {{ DRUPAL_CONTAINER }} bash -lc
|
|
"drush -r {{ DRUPAL_DOCKER_HTML_PATH }} cr"
|
|
changed_when: false
|