Files
ilnmors-homelab/ansible/roles/app/tasks/services/set_openwebui.yaml
T
2026-09-09 23:13:28 +09:00

85 lines
2.9 KiB
YAML

---
- name: Create openwebui directory
ansible.builtin.file:
path: "{{ node['home_path'] }}/{{ item }}"
state: "directory"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0770"
loop:
- "data/containers/openwebui"
- "data/containers/openwebui/data"
- "containers/openwebui"
- "containers/openwebui/ssl"
- name: Deploy root certificate
ansible.builtin.copy:
content: |
{{ hostvars['console']['ca']['root']['crt'] }}
dest: "{{ node['home_path'] }}/containers/openwebui/ssl/{{ root_cert_filename }}"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0440"
notify: "notification_restart_openwebui"
no_log: true
- name: Register secret value to podman secret
containers.podman.podman_secret:
name: "{{ item.name }}"
data: "{{ item.value }}"
state: "present"
force: true
loop:
- name: "OPEN_WEBUI_SECRET_KEY"
value: "{{ hostvars['console']['openwebui']['secret_key'] }}"
- name: "OPEN_WEBUI_POSTGRES_PASSWORD"
value: "{{ hostvars['console']['postgresql']['password']['openwebui'] }}"
- name: "OPEN_WEBUI_OAUTH_CLIENT_SECRET"
value: "{{ hostvars['console']['openwebui']['oidc']['secret'] }}"
notify: "notification_restart_openwebui"
no_log: true
- name: Pull image
containers.podman.podman_image:
name: "ghcr.io/open-webui/open-webui"
tag: "{{ version['containers']['openwebui'] }}"
state: "present"
pull: true
- name: Deploy container file
ansible.builtin.template:
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/openwebui/openwebui.container.j2"
dest: "{{ node['home_path'] }}/.config/containers/systemd/openwebui.container"
owner: "{{ ansible_user }}"
group: "{{ node['group'] }}"
mode: "0644"
notify: "notification_restart_openwebui"
- name: Enable openwebui.service
ansible.builtin.systemd:
name: "openwebui.service"
state: "started"
enabled: true
daemon_reload: true
scope: "user"
- name: Check container archive images
ansible.builtin.stat:
path: "{{ node['home_path'] }}/archives/containers/ghcr.io_open-webui_open-webui_{{ version['containers']['openwebui'] }}.tar"
register: container_archive_images
- name: Save container archive images
containers.podman.podman_save:
image:
- "ghcr.io/open-webui/open-webui:{{ version['containers']['openwebui'] }}"
dest: "{{ node['home_path'] }}/archives/containers/ghcr.io_open-webui_open-webui_{{ version['containers']['openwebui'] }}.tar"
format: "oci-archive"
force: false
when: not container_archive_images.stat.exists
- name: Fetch container archive images
ansible.builtin.fetch:
src: "{{ node['home_path'] }}/archives/containers/ghcr.io_open-webui_open-webui_{{ version['containers']['openwebui'] }}.tar"
dest: "{{ hostvars['console']['node']['data_path'] }}/images/containers/"
flat: true