added ollama role and host

This commit is contained in:
2026-08-05 11:21:54 +02:00
parent 25593dafa0
commit 6a3a1020db
12 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
---
# tasks file for roles/ollama
# systemd-Override, damit Ollama auf allen Interfaces lauscht (OLLAMA_HOST).
- name: ollama | configure | create systemd override directory
tags: ollama,configure
ansible.builtin.file:
path: /etc/systemd/system/ollama.service.d
state: directory
mode: '0755'
- name: ollama | configure | set OLLAMA_HOST via systemd override
tags: ollama,configure
ansible.builtin.template:
src: ollama-override.conf.j2
dest: /etc/systemd/system/ollama.service.d/override.conf
mode: '0644'
# Der Handler lädt systemd neu und startet den Dienst nur bei Änderungen neu.
notify: Reload systemd and restart Ollama
# Hinweis: Eine Firewall-Konfiguration (z.B. ufw) wird bewusst NICHT vorgenommen.

View File

@@ -0,0 +1,17 @@
---
# tasks file for roles/ollama
# Installation von Ollama über das offizielle Installationsskript.
- name: ollama | install | download official install script
tags: ollama,install
ansible.builtin.get_url:
url: "{{ ollama_install_script_url }}"
dest: "/tmp/ollama-install.sh"
mode: "0755"
- name: ollama | install | run official install script
tags: ollama,install
# Das Skript installiert das Binary nach /usr/local/bin/ollama.
# 'creates' sorgt für Idempotenz: Bei vorhandenem Binary wird die Ausführung übersprungen.
ansible.builtin.shell:
cmd: "/tmp/ollama-install.sh"
creates: /usr/local/bin/ollama

View File

@@ -0,0 +1,12 @@
---
# Load distro specific variables
- ansible.builtin.include_vars: "{{ ansible_facts['distribution'] | lower }}.yml"
tags: always
ignore_errors: True
- ansible.builtin.include_vars: "{{ ansible_facts['fqdn'] | lower }}.yml"
ignore_errors: True
- ansible.builtin.import_tasks: install.yml
- ansible.builtin.import_tasks: configure.yml
- ansible.builtin.import_tasks: service.yml
- ansible.builtin.import_tasks: models.yml

View File

@@ -0,0 +1,20 @@
---
# tasks file for roles/ollama
# Modellverwaltung: Es werden nur Modelle heruntergeladen, die noch nicht vorhanden sind.
- name: ollama | models | list installed models
tags: ollama,models
ansible.builtin.command: ollama list
register: ollama_installed_models
changed_when: false
# Kurzes Warten auf den frisch gestarteten Daemon beim Erstlauf (Retry-Muster wie omada-controller).
retries: 5
until: ollama_installed_models is success
delay: 2
- name: ollama | models | pull missing models
tags: ollama,models
ansible.builtin.command: ollama pull {{ item }}
loop: "{{ ollama_models }}"
# 'ollama list' führt die Modellnamen in der ersten Spalte auf; ein bereits
# vorhandenes Modell wird nicht erneut heruntergeladen.
when: item not in ollama_installed_models.stdout

View File

@@ -0,0 +1,8 @@
---
# tasks file for roles/ollama
- name: ollama | service | enable and start Ollama
tags: ollama,service
ansible.builtin.service:
name: ollama
state: started
enabled: true