M6: Modell-Sync + public read grant idempotent in open_webui-Rolle #14
@@ -17,3 +17,10 @@ milestone 6). Deployed by `playbooks/webui.yml` against
|
||||
- Daten: `/var/lib/ghostnet-ai/production/openwebui-data`.
|
||||
- Interne Phase: lokaler Auth (erster User = Admin). Die öffentliche
|
||||
OIDC-Phase (NPM-Route + Keycloak-Client) folgt in M6.
|
||||
|
||||
## Modellsichtbarkeit (v0.13 access control)
|
||||
|
||||
OpenWebUI zeigt Connection-Modelle Nicht-Admins nur, wenn ein DB-Model-Eintrag
|
||||
existiert UND ein public read access_grant (principal `user`/`*`) greift. Die
|
||||
Rolle stellt beides idempotent sicher (`open_webui_engine_model_id`), daher
|
||||
sehen alle authentifizierten OIDC-User das Modell im Chat-Dropdown.
|
||||
|
||||
@@ -24,6 +24,11 @@ open_webui_network_name: gnai-production-llama
|
||||
# internal network only.
|
||||
open_webui_egress_network_name: gnai-production-egress
|
||||
|
||||
# Engine model exposed in the chat UI. The model is synced into the OpenWebUI
|
||||
# DB and granted public read access (access_grant principal user "*"), so
|
||||
# every authenticated OIDC user sees it (GNAI-005: anwendungsbezogene Rechte).
|
||||
open_webui_engine_model_id: swift-1.5-qwen3.8-27b-q6k
|
||||
|
||||
# Engine endpoint inside the shared Production network. llama.cpp itself
|
||||
# has no auth; OpenWebUI just needs a non-empty key value, supplied via a
|
||||
# Podman secret (never in git).
|
||||
|
||||
@@ -233,6 +233,43 @@
|
||||
- not ansible_check_mode
|
||||
- open_webui_unit_state.rc != 0
|
||||
|
||||
- name: Ensure the engine model is synced and publicly readable in OpenWebUI
|
||||
# OpenWebUI shows connection models to non-admin users only when a DB model
|
||||
# row exists and a public read access_grant covers it (v0.13 access control).
|
||||
# Idempotent; touches only the app DB, no secrets.
|
||||
ansible.builtin.shell: |
|
||||
set -euo pipefail
|
||||
python3 - "{{ open_webui_data_dir }}/webui.db" "{{ open_webui_engine_model_id }}" <<'PYEOF'
|
||||
import sqlite3, sys, time, uuid
|
||||
db, model_id = sys.argv[1], sys.argv[2]
|
||||
con = sqlite3.connect(db)
|
||||
now = int(time.time())
|
||||
row = con.execute("select id from model where id=?", (model_id,)).fetchone()
|
||||
if not row:
|
||||
con.execute(
|
||||
"insert into model (id, user_id, base_model_id, name, params, meta, is_active, version_id, created_at, updated_at)"
|
||||
" values (?,?,?,?,?,?,?,?,?,?)",
|
||||
(model_id, "openwebui", None, model_id, "{}", "{}", 1, str(uuid.uuid4()), now, now),
|
||||
)
|
||||
grant = con.execute(
|
||||
"select id from access_grant where resource_type='model' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
||||
(model_id,),
|
||||
).fetchone()
|
||||
if not grant:
|
||||
con.execute(
|
||||
"insert into access_grant (id, resource_type, resource_id, principal_type, principal_id, permission, created_at)"
|
||||
" values (?,?,?,?,?,?,?)",
|
||||
(str(uuid.uuid4()), "model", model_id, "user", "*", "read", now),
|
||||
)
|
||||
con.commit()
|
||||
print("CHANGED" if (not row or not grant) else "UNCHANGED")
|
||||
PYEOF
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: not ansible_check_mode
|
||||
register: open_webui_model_sync
|
||||
changed_when: open_webui_model_sync.stdout_lines | first == 'CHANGED'
|
||||
|
||||
- name: Wait for the OpenWebUI health endpoint
|
||||
ansible.builtin.uri:
|
||||
url: "http://{{ open_webui_host_addr }}:{{ open_webui_host_port }}/health"
|
||||
|
||||
Reference in New Issue
Block a user