feat: add configuration for GPU node setup and update Ollama role for cross-platform support
This commit is contained in:
parent
d3069eb234
commit
0bf7f0f597
7
ansible/host_vars/debian.yaml
Normal file
7
ansible/host_vars/debian.yaml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Host vars for: debian (k3s storage agent)
|
||||||
|
ansible_python_interpreter: /usr/bin/python3.11
|
||||||
|
|
||||||
|
k3s_node_labels:
|
||||||
|
node-role: storage
|
||||||
|
|
||||||
|
k3s_node_taints: []
|
||||||
2
ansible/host_vars/minisforum.yaml
Normal file
2
ansible/host_vars/minisforum.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Host vars for: minisforum (k3s server)
|
||||||
|
ansible_python_interpreter: /usr/bin/python3.13
|
||||||
@ -23,3 +23,10 @@ all:
|
|||||||
mac-mini:
|
mac-mini:
|
||||||
ansible_host: 192.168.7.96
|
ansible_host: 192.168.7.96
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
|
||||||
|
gpu_workstation:
|
||||||
|
hosts:
|
||||||
|
gpu-node:
|
||||||
|
ansible_host: 192.168.7.98
|
||||||
|
ansible_port: 430
|
||||||
|
ansible_python_interpreter: /usr/bin/python3.12
|
||||||
12
ansible/playbooks/setup-gpu-node.yaml
Normal file
12
ansible/playbooks/setup-gpu-node.yaml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Config for: gpu-node workstation full setup
|
||||||
|
# Applied by: ansible-playbook -i ansible/inventory.yaml ansible/playbooks/setup-gpu-node.yaml
|
||||||
|
- name: gpu-node setup
|
||||||
|
hosts: gpu_workstation
|
||||||
|
become: true
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: common
|
||||||
|
- role: nvidia
|
||||||
|
- role: k3s-agent
|
||||||
|
- role: ollama
|
||||||
|
- role: glances
|
||||||
@ -1,7 +1,8 @@
|
|||||||
---
|
---
|
||||||
# Part of role: k3s-agent
|
# Part of role: k3s-agent
|
||||||
# Called by: ansible/playbooks/join-debian-agent.yaml
|
# Called by: ansible/playbooks/join-debian-agent.yaml
|
||||||
# Description: Installs K3s in agent mode, joins the cluster, and labels the node as storage.
|
# ansible/playbooks/setup-gpu-node.yaml
|
||||||
|
# Description: Installs K3s in agent mode, joins the cluster, labels and taints the node.
|
||||||
|
|
||||||
- name: Download and install K3s agent
|
- name: Download and install K3s agent
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
@ -20,11 +21,24 @@
|
|||||||
enabled: true
|
enabled: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
- name: Label node as storage
|
- name: Apply node labels
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: >
|
cmd: >
|
||||||
k3s kubectl label node nik-debian
|
k3s kubectl label node {{ ansible_hostname }}
|
||||||
node-role=storage --overwrite
|
{{ item.key }}={{ item.value }} --overwrite
|
||||||
|
loop: "{{ k3s_node_labels | dict2items }}"
|
||||||
delegate_to: minisforum
|
delegate_to: minisforum
|
||||||
become: true
|
become: true
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
when: k3s_node_labels is defined and k3s_node_labels | length > 0
|
||||||
|
|
||||||
|
- name: Apply node taints
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: >
|
||||||
|
k3s kubectl taint node {{ ansible_hostname }}
|
||||||
|
{{ item }} --overwrite
|
||||||
|
loop: "{{ k3s_node_taints }}"
|
||||||
|
delegate_to: minisforum
|
||||||
|
become: true
|
||||||
|
changed_when: false
|
||||||
|
when: k3s_node_taints is defined and k3s_node_taints | length > 0
|
||||||
@ -1,8 +1,17 @@
|
|||||||
---
|
---
|
||||||
# Part of role: ollama
|
# Part of role: ollama
|
||||||
# Called by: ansible/playbooks/setup-ollama.yaml
|
# Called by: ansible/playbooks/setup-ollama.yaml
|
||||||
# Description: Handlers for the ollama role. Restarts the ollama launchd daemon when the plist changes.
|
# ansible/playbooks/setup-gpu-node.yaml
|
||||||
|
# Description: Handlers for the ollama role. Restarts ollama on config changes.
|
||||||
- name: restart ollama
|
- name: restart ollama
|
||||||
become: true
|
become: true
|
||||||
command: launchctl kickstart -k system/com.ollama.ollama
|
command: launchctl kickstart -k system/com.ollama.ollama
|
||||||
|
when: ansible_system == 'Darwin'
|
||||||
|
|
||||||
|
- name: restart ollama linux
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: ollama
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
become: true
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
@ -1,12 +1,16 @@
|
|||||||
---
|
---
|
||||||
# Part of role: ollama
|
# Part of role: ollama
|
||||||
# Called by: ansible/playbooks/setup-ollama.yaml
|
# 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.
|
# ansible/playbooks/setup-gpu-node.yaml
|
||||||
|
# Description: Installs Ollama, configures it to bind to all interfaces, and pulls models.
|
||||||
|
# Supports macOS (Homebrew + launchd) and Linux (install script + systemd).
|
||||||
|
|
||||||
|
# ── macOS ──────────────────────────────────────────────────────────────────────
|
||||||
- name: Install ollama via Homebrew
|
- name: Install ollama via Homebrew
|
||||||
community.general.homebrew:
|
community.general.homebrew:
|
||||||
name: ollama
|
name: ollama
|
||||||
state: present
|
state: present
|
||||||
|
when: ansible_system == 'Darwin'
|
||||||
|
|
||||||
- name: Deploy ollama launchd plist
|
- name: Deploy ollama launchd plist
|
||||||
template:
|
template:
|
||||||
@ -17,6 +21,7 @@
|
|||||||
mode: "0644"
|
mode: "0644"
|
||||||
become: true
|
become: true
|
||||||
notify: restart ollama
|
notify: restart ollama
|
||||||
|
when: ansible_system == 'Darwin'
|
||||||
|
|
||||||
- name: Load ollama launchd service
|
- name: Load ollama launchd service
|
||||||
become: true
|
become: true
|
||||||
@ -24,7 +29,36 @@
|
|||||||
args:
|
args:
|
||||||
creates: /var/run/ollama.pid
|
creates: /var/run/ollama.pid
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
when: ansible_system == 'Darwin'
|
||||||
|
|
||||||
|
# ── Linux ──────────────────────────────────────────────────────────────────────
|
||||||
|
- name: Install ollama via install script
|
||||||
|
ansible.builtin.shell:
|
||||||
|
cmd: curl -fsSL https://ollama.com/install.sh | sh
|
||||||
|
creates: /usr/local/bin/ollama
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
|
- name: Deploy ollama systemd override
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: ollama-override.conf.j2
|
||||||
|
dest: /etc/systemd/system/ollama.service.d/override.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
become: true
|
||||||
|
notify: restart ollama linux
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
|
- name: Enable and start ollama service
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: ollama
|
||||||
|
state: started
|
||||||
|
enabled: true
|
||||||
|
daemon_reload: true
|
||||||
|
become: true
|
||||||
|
when: ansible_system == 'Linux'
|
||||||
|
|
||||||
|
# ── shared ─────────────────────────────────────────────────────────────────────
|
||||||
- name: Wait for ollama to be ready
|
- name: Wait for ollama to be ready
|
||||||
uri:
|
uri:
|
||||||
url: "http://localhost:{{ ollama_port }}"
|
url: "http://localhost:{{ ollama_port }}"
|
||||||
@ -41,7 +75,9 @@
|
|||||||
register: ollama_tags
|
register: ollama_tags
|
||||||
|
|
||||||
- name: Pull ollama models
|
- name: Pull ollama models
|
||||||
command: /opt/homebrew/bin/ollama pull {{ item }}
|
command: >
|
||||||
|
{{ '/opt/homebrew/bin/ollama' if ansible_system == 'Darwin' else '/usr/local/bin/ollama' }}
|
||||||
|
pull {{ item }}
|
||||||
loop: "{{ ollama_models }}"
|
loop: "{{ ollama_models }}"
|
||||||
when: item not in (ollama_tags.json.models | map(attribute='name') | list)
|
when: item not in (ollama_tags.json.models | map(attribute='name') | list)
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
5
ansible/roles/ollama/templates/ollama-override.conf.j2
Normal file
5
ansible/roles/ollama/templates/ollama-override.conf.j2
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# Managed by Ansible — do not edit manually
|
||||||
|
[Service]
|
||||||
|
Environment="OLLAMA_HOST=0.0.0.0"
|
||||||
|
Environment="OLLAMA_PORT={{ ollama_port }}"
|
||||||
|
Environment="OLLAMA_MODELS={{ ollama_models_dir | default('/usr/share/ollama/.ollama/models') }}"
|
||||||
Loading…
x
Reference in New Issue
Block a user