zeroclaw, addlogging for ollama service, fix ollama script ensuring all necessary variables exist;

This commit is contained in:
me
2026-10-06 17:23:01 -07:00
parent 5899f93a0a
commit 704955248b
+48 -5
View File
@@ -44,12 +44,23 @@
- name: Workstation | Linux | Software | ZeroClaw | Facts 02 - name: Workstation | Linux | Software | ZeroClaw | Facts 02
ansible.builtin.set_fact: ansible.builtin.set_fact:
ollama_runit_dir: "{{ runit_script_dir }}/{{ ollama }}" ollama_runit_dir: "{{ runit_script_dir }}/{{ ollama }}"
ollama_runit_log_dest: "{{ global_log }}/{{ ollama }}"
zeroclaw_runit_dir: "{{ runit_script_dir }}/{{ zeroclaw }}" zeroclaw_runit_dir: "{{ runit_script_dir }}/{{ zeroclaw }}"
zeroclaw_runit_log_dest: "{{ global_log }}/{{ zeroclaw }}"
- name: Workstation | Linux | Software | ZeroClaw | Facts 03 - name: Workstation | Linux | Software | ZeroClaw | Facts 03
ansible.builtin.set_fact: ansible.builtin.set_fact:
ollama_runit_start: "{{ ollama_runit_dir }}/{{ runit_service_script }}" ollama_runit_start: "{{ ollama_runit_dir }}/{{ runit_service_script }}"
zeroclaw_runit_start: "{{ zeroclaw_runit_dir }}{{ runit_service_script }}" ollama_runit_log_dir: "{{ ollama_runit_dir }}/{{ runit_log_dir }}"
ollama_runit_log_config: "{{ ollama_runit_log_dest }}/{{ global_log_config }}"
zeroclaw_runit_start: "{{ zeroclaw_runit_dir }}/{{ runit_service_script }}"
zeroclaw_runit_log_dir: "{{ zeroclaw_runit_dir }}/{{ runit_log_dir }}"
zeroclaw_runit_log_config: "{{ zeroclaw_runit_log_dest }}/{{ global_log_config }}"
- name: Workstation | Linux | Software | ZeroClaw | Facts 04
ansible.builtin.set_fact:
ollama_runit_log_start: "{{ ollama_runit_log_dir }}/{{ runit_log_script }}"
zeroclaw_runit_log_start: "{{ zeroclaw_runit_log_dir }}/{{ runit_log_script }}"
- name: Workstation | Linux | Software | ZeroClaw | Install - name: Workstation | Linux | Software | ZeroClaw | Install
ansible.builtin.package: ansible.builtin.package:
@@ -59,13 +70,14 @@
- "{{ zerocode }}" - "{{ zerocode }}"
state: present state: present
- name: Workstation | Linux | Software | ZeroClaw | ollama | Script [runit] - name: Workstation | Linux | Software | ZeroClaw | ollama | runit | Script
ansible.builtin.shell: "{{ item }}" ansible.builtin.shell: "{{ item }}"
loop: loop:
- "mkdir -p {{ ollama_runit_dir }}" - "mkdir -p {{ ollama_runit_dir }}"
- "echo '#!/bin/sh -e' > {{ ollama_runit_start }}" - "echo '#!/bin/sh -e' > {{ ollama_runit_start }}"
- "echo '# Allow pulling LLMs for use with ZeroClaw.' >> {{ ollama_runit_start }}" - "echo '# Allow pulling LLMs for use with ZeroClaw.' >> {{ ollama_runit_start }}"
- "echo 'exec 2>&1' >> {{ ollama_runit_start }}" - "echo 'exec 2>&1' >> {{ ollama_runit_start }}"
- "echo 'export HOME={{ user_user.home}}' >> {{ ollama_runit_start }}"
- "echo 'export OLLAMA_MAX_LOADED_MODELS=1' >> {{ ollama_runit_start }}" - "echo 'export OLLAMA_MAX_LOADED_MODELS=1' >> {{ ollama_runit_start }}"
- "echo 'exec chpst -u {{ user }} ollama serve' >> {{ ollama_runit_start }}" - "echo 'exec chpst -u {{ user }} ollama serve' >> {{ ollama_runit_start }}"
- "chmod +x {{ ollama_runit_start }}" - "chmod +x {{ ollama_runit_start }}"
@@ -73,13 +85,44 @@
changed_when: shell_check.rc == 0 changed_when: shell_check.rc == 0
when: ansible_service_mgr == "runit" when: ansible_service_mgr == "runit"
- name: Workstation | Linux | Software | ZeroClaw | ollama | runit | Log | Script
ansible.builtin.shell: "{{ item }}"
loop:
- "mkdir -p {{ ollama_runit_log_dir }}"
- "echo '#!/bin/sh -e' > {{ ollama_runit_log_start }}"
- "echo 'exec svlogd -tt {{ ollama_runit_log_dest }}' >> {{ ollama_runit_log_start }}"
- "chmod +x {{ ollama_runit_log_start }}"
register: shell_check
changed_when: shell_check.rc == 0
when: ansible_service_mgr == "runit"
- name: Workstation | Linux | Software | ZeroClaw | ollama | runit | Log | Config
ansible.builtin.shell: "{{ item }}"
loop:
- "mkdir -p {{ ollama_runit_log_dest }}"
- "echo 's10000000 # rotate at 10 MB' > {{ ollama_runit_log_config }}"
- "echo 'n5 # keep 5 old files' >> {{ ollama_runit_log_config }}"
register: shell_check
changed_when: shell_check.rc == 0
when: ansible_service_mgr == "runit"
- name: Workstation | Linux | Software | ZeroClaw | ollama | Enable - name: Workstation | Linux | Software | ZeroClaw | ollama | Enable
ansible.builtin.service: ansible.builtin.service:
name: "{{ ollama }}" name: "{{ ollama }}"
state: started state: started
enabled: true enabled: true
- name: Workstation | Linux | Software | ZeroClaw | Models | Install - name: Workstation | Linux | Software | ZeroClaw | ollama | Wait
ansible.builtin.uri:
url: http://127.0.0.1:11434/api/version
status_code: 200
timeout: 5
register: health
until: health.status == 200
retries: 12
delay: 5
- name: Workstation | Linux | Software | ZeroClaw | ollama | Models | Install
ansible.builtin.shell: | ansible.builtin.shell: |
set -o pipefail set -o pipefail
item='{{ item }}' item='{{ item }}'
@@ -87,7 +130,7 @@
echo "OKAY" && echo "OKAY" &&
return return
else else
ollama pull $item && ollama pull $item 1>/dev/null &&
echo "INSTALLED" && echo "INSTALLED" &&
return return
fi fi
@@ -99,7 +142,7 @@
become: true become: true
become_user: "{{ user }}" become_user: "{{ user }}"
- name: Workstation | Linux | Software | ZeroClaw | Models | Remove - name: Workstation | Linux | Software | ZeroClaw | ollama | Models | Remove
ansible.builtin.shell: | ansible.builtin.shell: |
set -o pipefail set -o pipefail
item='{{ item }}' item='{{ item }}'