Konflikte geloest: open_webui uebernimmt die origin-Branding-Struktur (files/theme + files/favicon, open_webui_theme_dir/favicon_mounts), meine Deep-Research-Pipe/-Tasks und der /app/build/favicon.png-Mount bleiben erhalten; files/branding-Duplikate entfernt. Link-Check OK (292 Links), beide Playbooks syntax-ok. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
676 lines
26 KiB
YAML
676 lines
26 KiB
YAML
---
|
|
- name: Verify open_webui role declarations
|
|
ansible.builtin.assert:
|
|
that:
|
|
- open_webui_image_ref is match('^ghcr.io/open-webui/open-webui@sha256:[0-9a-f]{64}$')
|
|
- open_webui_network_name == 'gnai-production-llama'
|
|
fail_msg: "open_webui must use the pinned digest and the Production network"
|
|
|
|
- name: Check whether the pinned OpenWebUI image is in the workload store
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- image
|
|
- exists
|
|
- "{{ open_webui_image_ref }}"
|
|
chdir: "{{ open_webui_home }}"
|
|
changed_when: false
|
|
failed_when: open_webui_image_present.rc not in [0, 1]
|
|
check_mode: false
|
|
register: open_webui_image_present
|
|
|
|
- name: Pull the pinned OpenWebUI image into the workload store
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- pull
|
|
- "{{ open_webui_image_ref }}"
|
|
chdir: "{{ open_webui_home }}"
|
|
when:
|
|
- not ansible_check_mode
|
|
- open_webui_image_present.rc != 0
|
|
|
|
- name: Ensure the OpenWebUI data directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ open_webui_data_dir }}"
|
|
state: directory
|
|
owner: "{{ open_webui_user }}"
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0750"
|
|
|
|
- name: Ensure the OpenWebUI theme directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ open_webui_theme_dir }}"
|
|
state: directory
|
|
owner: "{{ open_webui_user }}"
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0750"
|
|
|
|
- name: Deploy the GNMON theme as custom.css (read-only mount target, survives image updates)
|
|
# Single-file bind mounts pin the inode at container creation; Ansible copy
|
|
# replaces the file (rename -> new inode), so a content change MUST restart
|
|
# the unit to re-bind the current file. Hence the notify.
|
|
ansible.builtin.copy:
|
|
src: "files/{{ open_webui_theme_src }}"
|
|
dest: "{{ open_webui_theme_dir }}/{{ open_webui_theme_file }}"
|
|
owner: "{{ open_webui_user }}"
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0644"
|
|
notify: Restart OpenWebUI unit
|
|
|
|
- name: Ensure the OpenWebUI favicon directory exists
|
|
ansible.builtin.file:
|
|
path: "{{ open_webui_favicon_dir }}"
|
|
state: directory
|
|
owner: "{{ open_webui_user }}"
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0750"
|
|
|
|
- name: Deploy the ghost favicon files (read-only mount targets, survive image updates)
|
|
# Same inode caveat as the theme: content changes notify a unit restart.
|
|
ansible.builtin.copy:
|
|
src: "files/favicon/{{ item.host_file }}"
|
|
dest: "{{ open_webui_favicon_dir }}/{{ item.host_file }}"
|
|
owner: "{{ open_webui_user }}"
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0644"
|
|
loop: "{{ open_webui_favicon_mounts }}"
|
|
notify: Restart OpenWebUI unit
|
|
|
|
- name: Check whether the WebUI secret key already exists
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- secret
|
|
- exists
|
|
- "{{ open_webui_webui_secret_key_secret }}"
|
|
chdir: "{{ open_webui_home }}"
|
|
register: open_webui_secret_exists
|
|
changed_when: false
|
|
failed_when: open_webui_secret_exists.rc not in [0, 1]
|
|
check_mode: false
|
|
|
|
- name: Create the WebUI secret key (random, on the host only)
|
|
# Piped via stdin: a root-created temp file would not be readable by the
|
|
# workload user (umask), so the secret never touches the filesystem.
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
head -c 48 /dev/urandom | base64 \
|
|
| /usr/sbin/runuser --user {{ open_webui_user }} -- /usr/bin/env \
|
|
HOME={{ open_webui_home }} XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }} \
|
|
/usr/bin/podman secret create {{ open_webui_webui_secret_key_secret }} -
|
|
# runuser keeps the caller's cwd; the workload user cannot traverse
|
|
# /home/ansible-deploy, so run from the workload home.
|
|
args:
|
|
executable: /bin/bash
|
|
chdir: "{{ open_webui_home }}"
|
|
when: open_webui_secret_exists.rc == 1
|
|
no_log: true
|
|
|
|
- name: Check whether the engine API key secret already exists
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- secret
|
|
- exists
|
|
- "{{ open_webui_engine_api_key_secret }}"
|
|
chdir: "{{ open_webui_home }}"
|
|
register: open_webui_engine_secret_exists
|
|
changed_when: false
|
|
failed_when: open_webui_engine_secret_exists.rc not in [0, 1]
|
|
check_mode: false
|
|
|
|
- name: Create the engine API key secret (placeholder, llama.cpp has no auth)
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
printf 'local-noauth-%s' "$(head -c 16 /dev/urandom | base64)" \
|
|
| /usr/sbin/runuser --user {{ open_webui_user }} -- /usr/bin/env \
|
|
HOME={{ open_webui_home }} XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }} \
|
|
/usr/bin/podman secret create {{ open_webui_engine_api_key_secret }} -
|
|
args:
|
|
executable: /bin/bash
|
|
chdir: "{{ open_webui_home }}"
|
|
when: open_webui_engine_secret_exists.rc == 1
|
|
no_log: true
|
|
|
|
- name: Check whether the OIDC client secret exists (required when OIDC is enabled)
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- secret
|
|
- exists
|
|
- "{{ open_webui_oidc_client_secret_secret }}"
|
|
chdir: "{{ open_webui_home }}"
|
|
changed_when: false
|
|
failed_when: false
|
|
check_mode: false
|
|
register: open_webui_oidc_secret_exists
|
|
|
|
- name: Note when OIDC is enabled with a public (PKCE) client and no secret
|
|
ansible.builtin.debug:
|
|
msg: >-
|
|
OIDC enabled; Podman secret {{ open_webui_oidc_client_secret_secret }}
|
|
absent — fine for a public client with PKCE. For a confidential client,
|
|
create the secret from the Keycloak client secret (never in git).
|
|
when:
|
|
- open_webui_oidc_enabled | bool
|
|
- open_webui_oidc_secret_exists.rc != 0
|
|
|
|
- name: Render the egress network quadlet
|
|
ansible.builtin.template:
|
|
src: egress.network.j2
|
|
dest: "{{ open_webui_quadlet_dir }}/{{ open_webui_egress_network_name }}.network"
|
|
owner: root
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0640"
|
|
notify:
|
|
- Reload workload user manager
|
|
- Restart OpenWebUI unit
|
|
|
|
- name: Render the OpenWebUI quadlet
|
|
ansible.builtin.template:
|
|
src: open-webui.container.j2
|
|
dest: "{{ open_webui_quadlet_dir }}/{{ open_webui_unit_prefix }}.container"
|
|
owner: root
|
|
group: "{{ open_webui_user }}"
|
|
mode: "0640"
|
|
notify:
|
|
- Reload workload user manager
|
|
- Restart OpenWebUI unit
|
|
|
|
- name: Ensure the workload user manager knows the rendered unit
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/systemctl
|
|
- --user
|
|
- daemon-reload
|
|
chdir: "{{ open_webui_home }}"
|
|
changed_when: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: Read the current state of the OpenWebUI unit
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/systemctl
|
|
- --user
|
|
- is-active
|
|
- "{{ open_webui_unit_prefix }}.service"
|
|
chdir: "{{ open_webui_home }}"
|
|
changed_when: false
|
|
failed_when: open_webui_unit_state.rc not in [0, 3]
|
|
check_mode: false
|
|
register: open_webui_unit_state
|
|
|
|
- name: Start the OpenWebUI unit
|
|
# Quadlet-generated units are transient and cannot be `enable`d directly;
|
|
# the [Install] section of the quadlet handles boot enablement, here we
|
|
# only start (same pattern as the inference_engine role).
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/systemctl
|
|
- --user
|
|
- start
|
|
- "{{ open_webui_unit_prefix }}.service"
|
|
chdir: "{{ open_webui_home }}"
|
|
when:
|
|
- not ansible_check_mode
|
|
- open_webui_unit_state.rc != 0
|
|
|
|
- name: Ensure the engine model is synced, web-search capable 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).
|
|
# The row's meta also gets capabilities.web_search + builtinTools.web_search
|
|
# = true and defaultFeatureIds=["web_search"]: in v0.13.3 the builtin tools
|
|
# search_web/fetch_url are injected only when the capability and builtinTools
|
|
# category are set (utils/tools.py get_builtin_tools; they default to true,
|
|
# but setting them explicitly keeps API agents working even after a UI
|
|
# toggle), and a NEW chat starts with the web-search toggle ON only when
|
|
# defaultFeatureIds contains "web_search" (Chat.svelte defaultFeature()).
|
|
# Native function calling is the default tool-calling mode since v0.10, so
|
|
# params stay empty. 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 }}" "{{ open_webui_engine_model_name }}" <<'PYEOF'
|
|
import json, sqlite3, sys, time, uuid
|
|
db, model_id, model_name = sys.argv[1], sys.argv[2], sys.argv[3]
|
|
con = sqlite3.connect(db)
|
|
now = int(time.time())
|
|
changed = False
|
|
row = con.execute("select id, name, meta 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_name, "{}", "{}", 1, str(uuid.uuid4()), now, now),
|
|
)
|
|
changed = True
|
|
meta = {}
|
|
else:
|
|
meta = json.loads(row[2] or "{}")
|
|
if row[1] != model_name:
|
|
con.execute("update model set name=?, updated_at=? where id=?", (model_name, now, model_id))
|
|
changed = True
|
|
caps = meta.get("capabilities") or {}
|
|
builtin = meta.get("builtinTools") or {}
|
|
meta["capabilities"] = caps
|
|
meta["builtinTools"] = builtin
|
|
df = meta.get("defaultFeatureIds") or []
|
|
if (
|
|
caps.get("web_search") is not True
|
|
or builtin.get("web_search") is not True
|
|
or "web_search" not in df
|
|
):
|
|
caps["web_search"] = True
|
|
builtin["web_search"] = True
|
|
if "web_search" not in df:
|
|
meta["defaultFeatureIds"] = [*df, "web_search"]
|
|
con.execute("update model set meta=?, updated_at=? where id=?", (json.dumps(meta), now, model_id))
|
|
changed = True
|
|
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),
|
|
)
|
|
changed = True
|
|
con.commit()
|
|
print("CHANGED" if changed 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: Ensure the persisted web-search config matches the env (in v0.13 the DB config wins over env)
|
|
# OpenWebUI persists every ConfigVar in the `config` table and a saved value
|
|
# takes precedence over the environment variable ("the variable seeds the
|
|
# initial value, and the saved setting wins afterwards"). The env block
|
|
# seeds the container; this task aligns the DB rows so a stale value saved
|
|
# from the admin UI cannot silently disable web search. Config is read per
|
|
# request, no restart needed. Idempotent; touches only the app DB.
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
python3 - "{{ open_webui_data_dir }}/webui.db" '{{ open_webui_web_config | to_json }}' <<'PYEOF'
|
|
import json, sqlite3, sys, time
|
|
db, wanted_raw = sys.argv[1], sys.argv[2]
|
|
wanted = json.loads(wanted_raw)
|
|
now = int(time.time())
|
|
con = sqlite3.connect(db)
|
|
changed = False
|
|
for key, value in wanted.items():
|
|
row = con.execute("select value from config where key=?", (key,)).fetchone()
|
|
# the JSON column has NUMERIC affinity: numeric values come back as int
|
|
raw = row[0] if row else None
|
|
current = json.loads(raw) if isinstance(raw, str) else raw
|
|
if current != value:
|
|
con.execute(
|
|
"insert or replace into config (key, value, updated_at) values (?,?,?)",
|
|
(key, json.dumps(value), now),
|
|
)
|
|
changed = True
|
|
con.commit()
|
|
print("CHANGED" if changed else "UNCHANGED")
|
|
PYEOF
|
|
args:
|
|
executable: /bin/bash
|
|
vars:
|
|
open_webui_web_config:
|
|
web.search.enable: "{{ open_webui_env.ENABLE_WEB_SEARCH | lower == 'true' }}"
|
|
web.search.engine: "{{ open_webui_env.WEB_SEARCH_ENGINE }}"
|
|
web.search.searxng_query_url: "{{ open_webui_env.SEARXNG_QUERY_URL }}"
|
|
web.search.result_count: "{{ open_webui_env.WEB_SEARCH_RESULT_COUNT | int }}"
|
|
web.search.concurrent_requests: "{{ open_webui_env.WEB_SEARCH_CONCURRENT_REQUESTS | int }}"
|
|
web.fetch.max_content_length: "{{ open_webui_env.WEB_FETCH_MAX_CONTENT_LENGTH | int }}"
|
|
# DB config wins over env in v0.13: without ollama.enable=false the UI
|
|
# still calls /ollama/api/version on every model-list open (HTTP 500,
|
|
# no Ollama on this host). ui.default_models preselects the engine model
|
|
# in new chats.
|
|
ollama.enable: false
|
|
# comma-separated string, NOT a JSON list (Chat.svelte does .split(","))
|
|
ui.default_models: "{{ open_webui_default_models }}"
|
|
when: not ansible_check_mode
|
|
register: open_webui_web_config_sync
|
|
changed_when: open_webui_web_config_sync.stdout_lines | first == 'CHANGED'
|
|
|
|
- name: Stage the web-search tool sources on the host
|
|
ansible.builtin.copy:
|
|
src: "files/{{ item }}"
|
|
dest: "/tmp/{{ item }}"
|
|
mode: "0600"
|
|
loop:
|
|
- gnai-web-search-tool.py
|
|
- gnai-web-search-tool.specs.json
|
|
# The DB sync task below reports the real change; staging is plumbing.
|
|
changed_when: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: Ensure the API-agent web-search tool exists in OpenWebUI (SearXNG wrapper)
|
|
# In v0.13 the builtin tools (search_web/fetch_url) are only injected for
|
|
# UI-originated requests (session_id present); API callers must pass a
|
|
# workspace tool via `tool_ids` in the request body. This seeds one
|
|
# idempotently from role files (content + specs), with a public read grant.
|
|
# Idempotent; touches only the app DB, no secrets.
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
python3 - "{{ open_webui_data_dir }}/webui.db" \
|
|
/tmp/gnai-web-search-tool.py \
|
|
/tmp/gnai-web-search-tool.specs.json \
|
|
"{{ open_webui_web_search_tool_id }}" <<'PYEOF'
|
|
import json, sqlite3, sys, time, uuid
|
|
db, content_path, specs_path, tool_id = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4]
|
|
content = open(content_path).read()
|
|
specs = open(specs_path).read()
|
|
meta = json.dumps({"description": "Self-hosted SearXNG web search + URL fetch for API agents (GNAI-020). API callers: pass this tool id in tool_ids."})
|
|
now = int(time.time())
|
|
con = sqlite3.connect(db)
|
|
changed = False
|
|
row = con.execute("select content, specs, meta, is_active from tool where id=?", (tool_id,)).fetchone()
|
|
if not row:
|
|
con.execute(
|
|
"insert into tool (id, user_id, name, content, specs, meta, valves, updated_at, created_at, version_id, is_active)"
|
|
" values (?,?,?,?,?,?,?,?,?,?,?)",
|
|
(tool_id, "openwebui", "gnai-web-search", content, specs, meta, "{}", now, now, str(uuid.uuid4()), 1),
|
|
)
|
|
changed = True
|
|
elif row[0] != content or row[1] != specs or row[2] != meta or row[3] != 1:
|
|
con.execute(
|
|
"update tool set content=?, specs=?, meta=?, is_active=1, updated_at=?, version_id=? where id=?",
|
|
(content, specs, meta, now, str(uuid.uuid4()), tool_id),
|
|
)
|
|
changed = True
|
|
grant = con.execute(
|
|
"select id from access_grant where resource_type='tool' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
|
(tool_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()), "tool", tool_id, "user", "*", "read", now),
|
|
)
|
|
changed = True
|
|
con.commit()
|
|
print("CHANGED" if changed else "UNCHANGED")
|
|
PYEOF
|
|
args:
|
|
executable: /bin/bash
|
|
when: not ansible_check_mode
|
|
register: open_webui_tool_sync
|
|
changed_when: open_webui_tool_sync.stdout_lines | first == 'CHANGED'
|
|
|
|
- name: Remove the staged tool sources
|
|
ansible.builtin.file:
|
|
path: "/tmp/{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- gnai-web-search-tool.py
|
|
- gnai-web-search-tool.specs.json
|
|
changed_when: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: Stage the deep-research pipe source and verify its pinned sha256
|
|
# GNAI-022 (M6-R1 Phase 1): the pipe content is pinned by sha256 so a
|
|
# silent upstream edit can never reach the server; the DB sync task below
|
|
# reports the real change.
|
|
block:
|
|
- name: Stage the pipe source
|
|
ansible.builtin.copy:
|
|
src: files/gnai-deep-research-pipe.py
|
|
dest: /tmp/gnai-deep-research-pipe.py
|
|
mode: "0600"
|
|
changed_when: false
|
|
|
|
- name: Verify the pipe sha256 against the pinned value
|
|
ansible.builtin.command:
|
|
argv:
|
|
- sha256sum
|
|
- /tmp/gnai-deep-research-pipe.py
|
|
register: open_webui_pipe_hash
|
|
changed_when: false
|
|
failed_when: >-
|
|
open_webui_pipe_hash.stdout.split()[0] != open_webui_deep_research_pipe_sha256
|
|
|
|
- name: Ensure the deep-research pipe exists, is active and publicly readable in OpenWebUI
|
|
# Pipe functions (type='pipe') appear in the model selector with
|
|
# id=function.id; non-admin users only see them when a row in the `model`
|
|
# table exists for that id (plus a public read access_grant on
|
|
# resource_type='model'). Both are seeded here. Valves are stored as plain
|
|
# JSON (no secret fields). Idempotent; touches only the app DB.
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
python3 - "{{ open_webui_data_dir }}/webui.db" \
|
|
/tmp/gnai-deep-research-pipe.py \
|
|
'{{ open_webui_deep_research_valves | to_json }}' \
|
|
"{{ open_webui_deep_research_function_id }}" \
|
|
"{{ open_webui_deep_research_display_name }}" <<'PYEOF'
|
|
import json, sqlite3, sys, time, uuid
|
|
db, content_path, valves_raw, fn_id, fn_name = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]
|
|
content = open(content_path).read()
|
|
valves = json.loads(valves_raw)
|
|
meta = json.dumps({"description": "Iterativer Deep-Research-Loop (plan -> SearXNG -> fetch -> Synthese) auf der Production-Engine. GNAI-022 / GNAI-001 M6-R1."})
|
|
now = int(time.time())
|
|
con = sqlite3.connect(db)
|
|
changed = False
|
|
row = con.execute("select content, valves, meta, type, is_active, is_global, name from function where id=?", (fn_id,)).fetchone()
|
|
if not row:
|
|
con.execute(
|
|
"insert into function (id, version_id, user_id, name, type, content, meta, valves, is_active, is_global, updated_at, created_at)"
|
|
" values (?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
(fn_id, str(uuid.uuid4()), "openwebui", fn_name, "pipe", content, meta, json.dumps(valves), 1, 0, now, now),
|
|
)
|
|
changed = True
|
|
elif (
|
|
row[0] != content
|
|
or json.loads(row[1] or "{}") != valves
|
|
or row[2] != meta
|
|
or row[3] != "pipe"
|
|
or row[4] != 1
|
|
or row[5] != 0
|
|
or row[6] != fn_name
|
|
):
|
|
con.execute(
|
|
"update function set content=?, valves=?, meta=?, type='pipe', is_active=1, is_global=0, name=?, updated_at=?, version_id=? where id=?",
|
|
(content, json.dumps(valves), meta, fn_name, now, str(uuid.uuid4()), fn_id),
|
|
)
|
|
changed = True
|
|
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'",
|
|
(fn_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", fn_id, "user", "*", "read", now),
|
|
)
|
|
changed = True
|
|
# model row: without it, pipe models are visible to admins only
|
|
# (open-webui issue: "Pipe models without a model entry are shown to
|
|
# admins only"). With row + grant, every OIDC user sees the pipe.
|
|
mrow = con.execute("select name, meta, is_active from model where id=?", (fn_id,)).fetchone()
|
|
model_meta = json.dumps({"description": "Deep Research: iterativer plan→SearXNG→fetch→Synthese-Loop mit Quellen (GNAI-022). Engine: Production-llama.cpp, SearXNG: kuratiert."})
|
|
if not mrow:
|
|
con.execute(
|
|
"insert into model (id, user_id, base_model_id, name, params, meta, is_active, version_id, created_at, updated_at)"
|
|
" values (?,?,?,?,?,?,?,?,?,?)",
|
|
(fn_id, "openwebui", None, fn_name, "{}", model_meta, 1, str(uuid.uuid4()), now, now),
|
|
)
|
|
changed = True
|
|
elif mrow[0] != fn_name or mrow[1] != model_meta or mrow[2] != 1:
|
|
con.execute(
|
|
"update model set name=?, meta=?, is_active=1, updated_at=? where id=?",
|
|
(fn_name, model_meta, now, fn_id),
|
|
)
|
|
changed = True
|
|
con.commit()
|
|
print("CHANGED" if changed else "UNCHANGED")
|
|
PYEOF
|
|
args:
|
|
executable: /bin/bash
|
|
when: not ansible_check_mode
|
|
register: open_webui_pipe_sync
|
|
changed_when: open_webui_pipe_sync.stdout_lines | first == 'CHANGED'
|
|
|
|
- name: Verify the deep-research pipe row and grant in webui.db
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
python3 - "{{ open_webui_data_dir }}/webui.db" "{{ open_webui_deep_research_function_id }}" <<'PYEOF'
|
|
import json, sqlite3, sys
|
|
con = sqlite3.connect(sys.argv[1])
|
|
fn_id = sys.argv[2]
|
|
row = con.execute("select type, is_active, valves from function where id=?", (fn_id,)).fetchone()
|
|
assert row, "function row missing"
|
|
assert row[0] == "pipe" and row[1] == 1, "pipe not active"
|
|
valves = json.loads(row[2])
|
|
assert valves.get("SEARXNG_URL"), "SEARXNG_URL valve missing"
|
|
grant = con.execute(
|
|
"select count(*) from access_grant where resource_type='model' and resource_id=? and principal_type='user' and principal_id='*' and permission='read'",
|
|
(fn_id,),
|
|
).fetchone()[0]
|
|
assert grant == 1, "public read grant missing"
|
|
mrow = con.execute("select is_active from model where id=?", (fn_id,)).fetchone()
|
|
assert mrow and mrow[0] == 1, "model row for pipe missing (pipe would be admin-only)"
|
|
print("PIPE-OK")
|
|
PYEOF
|
|
args:
|
|
executable: /bin/bash
|
|
register: open_webui_pipe_verify
|
|
changed_when: false
|
|
failed_when: "'PIPE-OK' not in open_webui_pipe_verify.stdout"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Remove the staged pipe source
|
|
ansible.builtin.file:
|
|
path: /tmp/gnai-deep-research-pipe.py
|
|
state: absent
|
|
changed_when: false
|
|
- name: Flush handlers before the served checks
|
|
# Content changes to the ro-mounted files notify "Restart OpenWebUI unit";
|
|
# the restart must happen BEFORE the served checks, otherwise they test the
|
|
# stale inode still bound by the running container.
|
|
ansible.builtin.meta: flush_handlers
|
|
when: not ansible_check_mode
|
|
|
|
- name: Wait for the OpenWebUI health endpoint
|
|
ansible.builtin.uri:
|
|
url: "http://{{ open_webui_host_addr }}:{{ open_webui_host_port }}/health"
|
|
status_code: 200
|
|
timeout: 10
|
|
register: open_webui_health
|
|
retries: 30
|
|
delay: 5
|
|
until: open_webui_health.status == 200
|
|
when: not ansible_check_mode
|
|
|
|
- name: Verify the GNMON theme is served as /static/custom.css (non-empty, marker present)
|
|
# Guards the update-persistence contract: if a future OpenWebUI image stops
|
|
# referencing or serving custom.css, this fails instead of silently losing
|
|
# the theme.
|
|
ansible.builtin.uri:
|
|
url: "http://{{ open_webui_host_addr }}:{{ open_webui_host_port }}/static/custom.css"
|
|
status_code: 200
|
|
timeout: 10
|
|
return_content: true
|
|
register: open_webui_theme_served
|
|
failed_when: "'gnai-catppuccin-mocha' not in open_webui_theme_served.content"
|
|
when: not ansible_check_mode
|
|
|
|
- name: Stat the deployed favicon for the served-size comparison
|
|
ansible.builtin.stat:
|
|
path: "{{ open_webui_favicon_dir }}/favicon.png"
|
|
register: open_webui_favicon_stat
|
|
when: not ansible_check_mode
|
|
|
|
- name: Verify the ghost favicon is served as /static/favicon.png (byte-identical to the deployed file)
|
|
ansible.builtin.uri:
|
|
url: "http://{{ open_webui_host_addr }}:{{ open_webui_host_port }}/static/favicon.png"
|
|
status_code: 200
|
|
timeout: 10
|
|
register: open_webui_favicon_served
|
|
failed_when: >-
|
|
open_webui_favicon_served.content_length | int
|
|
!= open_webui_favicon_stat.stat.size | int
|
|
when: not ansible_check_mode
|
|
|
|
- name: Verify the engine model list is reachable through OpenWebUI's network
|
|
ansible.builtin.command:
|
|
argv:
|
|
- /usr/sbin/runuser
|
|
- --user
|
|
- "{{ open_webui_user }}"
|
|
- --
|
|
- /usr/bin/env
|
|
- "HOME={{ open_webui_home }}"
|
|
- "XDG_RUNTIME_DIR=/run/user/{{ open_webui_uid }}"
|
|
- /usr/bin/podman
|
|
- exec
|
|
- "{{ open_webui_unit_prefix }}"
|
|
- /bin/sh
|
|
- -c
|
|
- "curl -fsS --max-time 10 {{ open_webui_engine_base_url }}/models | grep -q swift"
|
|
chdir: "{{ open_webui_home }}"
|
|
register: open_webui_models
|
|
changed_when: false
|
|
when: not ansible_check_mode
|