Files
ouranos/ansible/openwebui/deploy.yml
Robert Helewka 042df52bca Refactor user management in Ansible playbooks to standardize on keeper_user
- Updated user addition tasks across multiple playbooks (mcp_switchboard, mcpo, neo4j, neo4j_mcp, openwebui, postgresql, rabbitmq, searxng, smtp4dev) to replace references to ansible_user and remote_user with keeper_user.
- Modified PostgreSQL deployment to create directories and manage files under keeper_user's home.
- Enhanced documentation to clarify account taxonomy and usage of keeper_user in playbooks.
- Introduced new deployment for Agent S, including environment setup, desktop environment installation, XRDP configuration, and accessibility support.
- Added staging playbook for preparing release tarballs from local repositories.
- Created templates for XRDP configuration and environment activation scripts.
- Removed obsolete sunwait documentation.
2026-03-05 10:37:41 +00:00

128 lines
3.4 KiB
YAML

---
- name: Install OpenWebUI configured with PostgreSQL
hosts: ubuntu
vars:
ansible_common_remote_group: "{{ openwebui_group | default(omit) }}"
allow_world_readable_tmpfiles: true
tasks:
- name: Check if host has openwebui service
ansible.builtin.set_fact:
has_openwebui_service: "{{ 'openwebui' in services | default([]) }}"
- name: Skip hosts without openwebui service
ansible.builtin.meta: end_host
when: not has_openwebui_service
- name: Create OpenWebUI User
become: true
ansible.builtin.user:
name: "{{openwebui_user}}"
comment: "{{openwebui_user}}"
system: true
- name: Add keeper_user to OpenWebUI group
become: true
ansible.builtin.user:
name: "{{keeper_user}}"
groups: "{{openwebui_group}}"
append: true
- name: Create OpenWebUI directory
become: true
ansible.builtin.file:
path: "{{openwebui_directory}}"
owner: "{{openwebui_user}}"
group: "{{openwebui_group}}"
state: directory
mode: '0750'
- name: Install required packages
become: true
ansible.builtin.apt:
name: [postgresql-client, ffmpeg]
state: present
update_cache: true
- name: Install Python 3.12 and venv
become: true
ansible.builtin.apt:
name: [python3.12, python3.12-venv, python3.12-dev]
state: latest
update_cache: true
- name: Create virtual environment
become: true
become_user: "{{openwebui_user}}"
ansible.builtin.command: python3.12 -m venv {{openwebui_directory}}/.venv
args:
creates: "{{openwebui_directory}}/.venv/bin/activate"
- name: Install wheel and openwebui in virtual environment
become: true
become_user: "{{openwebui_user}}"
ansible.builtin.pip:
name:
- wheel
- open-webui[all]=={{openwebui_rel}}
- psycopg2-binary
state: latest
virtualenv: "{{openwebui_directory}}/.venv"
virtualenv_python: python3.12
vars:
ansible_common_remote_group: "{{openwebui_group}}"
allow_world_readable_tmpfiles: true
notify: Restart OpenWebUI
- name: Create environment file for OpenWebUI
become: true
ansible.builtin.template:
src: openwebui.env.j2
dest: "{{openwebui_directory}}/.env"
owner: "{{openwebui_user}}"
group: "{{openwebui_group}}"
mode: '0600'
notify: Restart OpenWebUI
- name: Create systemd service file
become: true
ansible.builtin.template:
src: openwebui.service.j2
dest: /etc/systemd/system/openwebui.service
mode: '0644'
notify: Restart OpenWebUI
- name: Enable openwebui service
become: true
ansible.builtin.systemd:
name: openwebui
daemon_reload: true
enabled: true
handlers:
- name: Restart OpenWebUI
become: true
ansible.builtin.systemd:
name: openwebui
daemon_reload: true
state: restarted
post_tasks:
- name: Wait for OpenWebUI to initialize database schema
ansible.builtin.pause:
seconds: 20
prompt: "Waiting for OpenWebUI to initialize the database schema..."
- name: Check if OpenWebUI is running
ansible.builtin.uri:
url: http://localhost:{{openwebui_port}}/
method: GET
status_code: 200
timeout: 5
register: openwebui_status
ignore_errors: true
- name: Show OpenWebUI status
ansible.builtin.debug:
msg: "OpenWebUI is {{ 'running' if openwebui_status.status == 200 else 'not running properly' }}"