feat: add model checking and conditional pulling for Ollama models

This commit is contained in:
Nik Afiq 2026-04-21 22:53:25 +09:00
parent 54d368d462
commit f0bef8e4c1
2 changed files with 9 additions and 1 deletions

View File

@ -7,3 +7,4 @@ ollama_host: "0.0.0.0"
ollama_port: 11434 ollama_port: 11434
ollama_models: ollama_models:
- qwen3:4b - qwen3:4b
- llama3

View File

@ -34,8 +34,15 @@
retries: 10 retries: 10
delay: 3 delay: 3
- name: Check installed ollama models
uri:
url: "http://localhost:{{ ollama_port }}/api/tags"
return_content: true
register: ollama_tags
- name: Pull ollama models - name: Pull ollama models
command: /opt/homebrew/bin/ollama pull {{ item }} command: /opt/homebrew/bin/ollama pull {{ item }}
loop: "{{ ollama_models }}" loop: "{{ ollama_models }}"
when: item not in (ollama_tags.json.models | map(attribute='name') | list)
environment: environment:
OLLAMA_HOST: "http://localhost:{{ ollama_port }}" OLLAMA_HOST: "http://localhost:{{ ollama_port }}"