48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
---
|
|
# Part of role: ollama
|
|
# Called by: ansible/playbooks/setup-ollama.yaml
|
|
# Description: Installs Ollama via Homebrew, deploys the launchd plist so it starts on boot bound to all interfaces, and pulls configured models.
|
|
|
|
- name: Install ollama via Homebrew
|
|
community.general.homebrew:
|
|
name: ollama
|
|
state: present
|
|
|
|
- name: Deploy ollama launchd plist
|
|
template:
|
|
src: ollama.plist.j2
|
|
dest: /Library/LaunchDaemons/com.ollama.ollama.plist
|
|
owner: root
|
|
group: wheel
|
|
mode: "0644"
|
|
become: true
|
|
notify: restart ollama
|
|
|
|
- name: Load ollama launchd service
|
|
become: true
|
|
command: launchctl load -w /Library/LaunchDaemons/com.ollama.ollama.plist
|
|
args:
|
|
creates: /var/run/ollama.pid
|
|
ignore_errors: true
|
|
|
|
- name: Wait for ollama to be ready
|
|
uri:
|
|
url: "http://localhost:{{ ollama_port }}"
|
|
status_code: 200
|
|
register: result
|
|
until: result.status == 200
|
|
retries: 10
|
|
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
|
|
command: /opt/homebrew/bin/ollama pull {{ item }}
|
|
loop: "{{ ollama_models }}"
|
|
when: item not in (ollama_tags.json.models | map(attribute='name') | list)
|
|
environment:
|
|
OLLAMA_HOST: "http://localhost:{{ ollama_port }}" |