feat: initial commit — Ansible roles storage-01/gpu-01 opérationnels

This commit is contained in:
alkatrazz 2026-05-12 17:17:03 +02:00
commit b3fce8af5d
70 changed files with 2688 additions and 0 deletions

View file

@ -0,0 +1,15 @@
---
llama_server_port: 1234
llama_server_host: "0.0.0.0"
llama_amdgpu_targets: "gfx1030"
rocm_path: "/opt/rocm"
hsa_override_gfx_version: "10.3.0"
# Modèle à charger au démarrage
llama_model_path: ""
llama_model_alias: ""
llama_ctx_size: 32768
llama_n_gpu_layers: 99
llama_parallel: 1
llama_embeddings: true
llama_pooling: "mean"

View file

@ -0,0 +1,9 @@
---
- name: Reload systemd
ansible.builtin.systemd:
daemon_reload: true
- name: Restart llama-server
ansible.builtin.systemd:
name: llama-server
state: restarted

View file

@ -0,0 +1,79 @@
---
- name: Install build dependencies
ansible.builtin.dnf:
name:
- cmake
- gcc-c++
- git
- patchelf
- hipblas-devel
- rocblas-devel
- hip-devel
- hipcc
state: present
- name: Clone llama.cpp
ansible.builtin.git:
repo: https://github.com/ggerganov/llama.cpp
dest: /opt/llama.cpp
depth: 1
version: "{{ llama_server_commit | default('HEAD') }}"
register: llama_clone
- name: Check if llama-server binary exists
ansible.builtin.stat:
path: /opt/llama.cpp/build/bin/llama-server
register: llama_server_binary_stat
- name: Configure cmake build (ROCm HIP)
ansible.builtin.command:
cmd: >
cmake -B build
-DGGML_HIP=ON
-DAMDGPU_TARGETS={{ llama_amdgpu_targets }}
-DCMAKE_BUILD_TYPE=Release
-DROCM_PATH={{ rocm_path }}
-DCMAKE_PREFIX_PATH={{ rocm_path }}
-DCMAKE_HIP_COMPILER={{ rocm_path }}/llvm/bin/clang++
chdir: /opt/llama.cpp
environment:
PATH: "{{ rocm_path }}/bin:{{ ansible_env.PATH }}"
when: llama_clone is changed or not llama_server_binary_stat.stat.exists
- name: Build llama-server
ansible.builtin.command:
cmd: cmake --build build --target llama-server -j{{ ansible_processor_nproc }}
chdir: /opt/llama.cpp
environment:
PATH: "{{ rocm_path }}/bin:{{ ansible_env.PATH }}"
when: llama_clone is changed or not llama_server_binary_stat.stat.exists
- name: Deploy systemd service
ansible.builtin.template:
src: llama-server.service.j2
dest: /etc/systemd/system/llama-server.service
mode: '0644'
notify:
- Reload systemd
- Restart llama-server
- name: Enable llama-server service
ansible.builtin.systemd:
name: llama-server
enabled: true
daemon_reload: true
state: started
- name: Open port in firewall
ansible.posix.firewalld:
port: "{{ llama_server_port }}/tcp"
permanent: true
state: enabled
immediate: true
- name: Disable lm-studio service (replaced by llama-server)
ansible.builtin.systemd:
name: lm-studio
enabled: false
state: stopped
ignore_errors: true

View file

@ -0,0 +1,28 @@
[Unit]
Description=llama-server (llama.cpp OpenAI-compatible API)
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=root
Environment=HSA_OVERRIDE_GFX_VERSION={{ hsa_override_gfx_version }}
Environment=LD_LIBRARY_PATH={{ rocm_path }}/lib
ExecStart=/opt/llama.cpp/build/bin/llama-server \
--model {{ llama_model_path }} \
--host {{ llama_server_host }} \
--port {{ llama_server_port }} \
--ctx-size {{ llama_ctx_size }} \
--n-gpu-layers {{ llama_n_gpu_layers }} \
--parallel {{ llama_parallel }} \
--alias {{ llama_model_alias }} \
{% if llama_embeddings %}
--embeddings \
--pooling {{ llama_pooling }} \
{% endif %}
--log-disable
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target