From 8970b14e314ec21985dad0be90a7085a68340730 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sat, 10 Oct 2026 10:28:45 -0700 Subject: [PATCH] llm, always do the setup steps, then XYZ_enabled vars are used to disable and stop services not wanted. --- tasks/workstation/linux/software/llm.yml | 171 +++++++++++------------ 1 file changed, 84 insertions(+), 87 deletions(-) diff --git a/tasks/workstation/linux/software/llm.yml b/tasks/workstation/linux/software/llm.yml index 77063be..7ec6815 100644 --- a/tasks/workstation/linux/software/llm.yml +++ b/tasks/workstation/linux/software/llm.yml @@ -296,100 +296,97 @@ mode: "0755" - - name: Workstation | Linux | Software | LLMs | runit | open-webui - block: - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages - ansible.builtin.package: - name: - - docker - state: present - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages | init - ansible.builtin.package: - name: - - docker-runit - state: present - when: ansible_pkg_mgr == "pacman" - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /etc/sv - ansible.builtin.file: - name: "/etc/sv/open_webui/log" - state: directory - owner: root - mode: "0755" - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /var/log - ansible.builtin.file: - name: "/var/log/open_webui" - state: directory - owner: "{{ user }}" - mode: "0755" - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | File - ansible.builtin.copy: - dest: /etc/sv/open_webui/run - content: | - #!/bin/sh - exec 2>&1 - - # Wait for Docker to start up. - while [ ! -S /var/run/docker.sock ]; do sleep 1; done - - # Ensure the old container is gone. - echo "Stopping..." - docker stop open-webui && - echo "Container stopped" || - echo "Container already stopped." - echo "Deleting..." - docker rm -f open-webui && - echo "Container deleted" || - echo "Container already deleted." - - # Start the open-webui program. - set -e - exec docker run --rm \ - -p {{ open_webui_port }}:8080 \ - --add-host=host.docker.internal:host-gateway \ - -v open-webui:/app/backend/data \ - {{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \ - -e WEBUI_SECRET_KEY={{ open_webui_key }} \ - -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \ - --name open-webui \ - ghcr.io/open-webui/open-webui:main - mode: "0755" - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log - ansible.builtin.copy: - dest: /etc/sv/open_webui/log/run - content: | - #!/bin/sh -e - exec svlogd -tt /var/log/open_webui - mode: "0755" - - - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log Config - ansible.builtin.copy: - dest: /var/log/open_webui/config - content: | - s1000000 # rotate at 1 MB - n5 # keep 5 old files - dateformat %Y-%m-%d_%H-%M-%S # each run gets its own file. - mode: "0755" - + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages + ansible.builtin.package: + name: + - docker + state: present when: open_webui_enabled + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Packages | init + ansible.builtin.package: + name: + - docker-runit + state: present + when: open_webui_enabled + and ansible_pkg_mgr == "pacman" + + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /etc/sv + ansible.builtin.file: + name: "/etc/sv/open-webui/log" + state: directory + owner: root + mode: "0755" + + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Dir | /var/log + ansible.builtin.file: + name: "/var/log/open-webui" + state: directory + owner: "{{ user }}" + mode: "0755" + + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | File + ansible.builtin.copy: + dest: /etc/sv/open-webui/run + content: | + #!/bin/sh + exec 2>&1 + + # Wait for Docker to start up. + while [ ! -S /var/run/docker.sock ]; do sleep 1; done + + # Ensure the old container is gone. + echo "Stopping..." + docker stop open-webui && + echo "Container stopped" || + echo "Container already stopped." + echo "Deleting..." + docker rm -f open-webui && + echo "Container deleted" || + echo "Container already deleted." + + # Start the open-webui program. + set -e + exec docker run --rm \ + -p {{ open_webui_port }}:8080 \ + --add-host=host.docker.internal:host-gateway \ + -v open-webui:/app/backend/data \ + {{ ("-e HF_TOKEN=" ~ hf_token) if hf_token else '' }} \ + -e WEBUI_SECRET_KEY={{ open_webui_key }} \ + -e OLLAMA_BASE_URL=http://host.docker.internal:11434 \ + --name open-webui \ + ghcr.io/open-webui/open-webui:main + mode: "0755" + + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log + ansible.builtin.copy: + dest: /etc/sv/open-webui/log/run + content: | + #!/bin/sh -e + exec svlogd -tt /var/log/open-webui + mode: "0755" + + - name: Workstation | Linux | Software | LLMs | runit | open-webui | Script | Log Config + ansible.builtin.copy: + dest: /var/log/open-webui/config + content: | + s1000000 # rotate at 1 MB + n5 # keep 5 old files + dateformat %Y-%m-%d_%H-%M-%S # each run gets its own file. + mode: "0755" + when: ansible_service_mgr == "runit" - name: Workstation | Linux | Software | LLMs | Services | Enable ansible.builtin.service: - name: "{{ item }}" - state: started - enabled: true + name: "{{ item.name }}" + state: "{{ 'started' if item.status else 'stopped' }}" + enabled: "{{ item.status }}" loop: - - "{{ ollama if ollama_enabled else dummy_service }}" - - "{{ zeroclaw if zeroclaw_enabled else dummy_service }}" - - "{{ 'docker' if open_webui_enabled else dummy_service }}" - - "{{ 'open_webui' if open_webui_enabled else dummy_service }}" + - { 'name': "{{ ollama }}" , 'status': "{{ ollama_enabled }}" } + - { 'name': "{{ zeroclaw }}", 'status': "{{ zeroclaw_enabled }}" } + - { 'name': 'docker' , 'status': true } + - { 'name': 'open-webui' , 'status': "{{ open_webui_enabled }}" } - name: Workstation | Linux | Software | LLMs | Services | Verify ansible.builtin.uri: