/
/
/
Ansible role that deployes services on my runner machine
1---
2# Runner Services - Unified LLM Stack Deployment
3# Single deployment with Ollama, OpenWebUI, and LiteLLM services
4
5- name: Check if LLM stack is enabled
6 fail:
7 msg: "LLM stack is disabled. Set llm_stack_enabled: true to enable."
8 when: not llm_stack_enabled
9 tags: always
10
11- name: Create LLM stack configuration directory structure
12 file:
13 path: "{{ item }}"
14 state: directory
15 owner: "{{ runner_user }}"
16 group: "{{ runner_group }}"
17 mode: '0775'
18 loop:
19 - "{{ llm_stack_config_dir }}"
20 - "{{ llm_stack_ollama_data_dir }}"
21 - "{{ llm_stack_openwebui_data_dir }}"
22 - "{{ llm_stack_litellm_data_dir }}"
23
24- name: Set group sticky bit on LLM stack directories for permission inheritance
25 file:
26 path: "{{ llm_stack_config_dir }}"
27 state: directory
28 mode: "g+s"
29
30- name: Create unified LLM stack Docker Compose file
31 template:
32 src: llm-stack-compose.yml.j2
33 dest: "{{ llm_stack_config_dir }}/docker-compose.yml"
34 owner: "{{ runner_user }}"
35 group: "{{ runner_group }}"
36 mode: '0664'
37 notify: restart llm-stack
38
39- name: Create unified LLM stack environment file
40 template:
41 src: llm-stack.env.j2
42 dest: "{{ llm_stack_config_dir }}/.env"
43 owner: "{{ runner_user }}"
44 group: "{{ runner_group }}"
45 mode: '0664'
46 notify: restart llm-stack
47
48- name: Create LiteLLM environment file
49 template:
50 src: llm-stack-litellm.env.j2
51 dest: "{{ llm_stack_config_dir }}/litellm.env"
52 owner: "{{ runner_user }}"
53 group: "{{ runner_group }}"
54 mode: '0664'
55 notify: restart llm-stack
56
57- name: Create LiteLLM proxy configuration
58 template:
59 src: llm-stack-litellm-config.yml.j2
60 dest: "{{ llm_stack_config_dir }}/litellm-config.yaml"
61 owner: "{{ runner_user }}"
62 group: "{{ runner_group }}"
63 mode: '0664'
64 notify: restart llm-stack
65
66- name: Start unified LLM stack service
67 community.docker.docker_compose_v2:
68 project_src: "{{ llm_stack_config_dir }}"
69 state: present
70 register: llm_stack_start_result
71 check_mode: no
72
73- name: Wait for Ollama to be healthy
74 uri:
75 url: "http://localhost:{{ llm_stack_ollama_port }}/api/tags"
76 method: GET
77 status_code: 200
78 register: ollama_health
79 until: ollama_health.status == 200
80 retries: 30
81 delay: 10
82 when: llm_stack_start_result is changed
83 check_mode: no
84
85- name: Wait for OpenWebUI to be healthy
86 uri:
87 url: "http://localhost:{{ llm_stack_openwebui_port }}/api/health"
88 method: GET
89 status_code: 200
90 timeout: 30
91 register: openwebui_health
92 until: openwebui_health.status == 200
93 retries: 60
94 delay: 15
95 when: llm_stack_start_result is changed
96 check_mode: no
97
98- name: Wait for LiteLLM PostgreSQL to be healthy
99 wait_for:
100 host: localhost
101 port: "{{ llm_stack_litellm_port }}"
102 timeout: 30
103 when: llm_stack_start_result is changed
104 check_mode: no
105
106- name: Wait for LiteLLM to be healthy
107 uri:
108 url: "http://localhost:{{ llm_stack_litellm_port }}/"
109 method: GET
110 status_code: 200
111 register: litellm_health
112 until: litellm_health.status == 200
113 retries: 10
114 delay: 10
115 when: llm_stack_start_result is changed
116 check_mode: no
117
118- name: Display unified LLM stack deployment summary
119 debug:
120 msg: |
121 Unified LLM Stack Deployment:
122 - Status: {{ 'Started' if llm_stack_start_result is changed else 'Already running' }}
123
124 Ollama (Local LLM Server):
125 - Web UI: http://{{ ansible_default_ipv4.address }}:{{ llm_stack_ollama_port }}
126 - Configuration: {{ llm_stack_config_dir }}
127 - Data Storage: {{ llm_stack_ollama_data_dir }}
128 - GPU Support: {{ 'Enabled' if gpu_enabled else 'Disabled' }}
129 - Default Model: {{ llm_stack_ollama_default_model }}
130
131 OpenWebUI (Web Interface):
132 - Web UI: http://{{ ansible_default_ipv4.address }}:{{ llm_stack_openwebui_port }}
133 - Connected to Ollama: ollama:11434
134 - Name: {{ llm_stack_openwebui_name }}
135
136 LiteLLM (Unified Proxy):
137 - API Endpoint: http://{{ ansible_default_ipv4.address }}:{{ llm_stack_litellm_port }}
138 - Connected to Ollama: ollama:11434
139 - Available Models:
140 {% for model in llm_stack_models %}
141 - {{ model.name }} ({{ model.role }}): {{ model.description }}
142 {% endfor %}
143
144 Management Commands:
145 - cd {{ llm_stack_config_dir }} && docker compose logs -f
146 - cd {{ llm_stack_config_dir }} && docker compose restart
147 - cd {{ llm_stack_config_dir }} && docker compose ps