feat: add ComfyUI integration with Ansible playbook

- Add ComfyUI installation to Ansible playbook with 'comfyui' tag
- Create ComfyUI requirements.txt and start.sh script
- Clone ComfyUI from official GitHub repository
- Symlink HuggingFace cache for Flux model access
- ComfyUI runs on port 8188 with CORS enabled
- Add ComfyUI to services list in playbook

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-21 20:41:43 +01:00
parent 538609da3e
commit 205e591fb4
3 changed files with 118 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
torch
torchvision
torchaudio
transformers
diffusers
accelerate
safetensors
omegaconf
einops
kornia
spandrel
soundfile

29
models/comfyui/start.sh Normal file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
#
# ComfyUI Startup Script
# Starts ComfyUI server on port 8188
#
WORKSPACE_DIR="${WORKSPACE_DIR:-/workspace}"
COMFYUI_DIR="${WORKSPACE_DIR}/ComfyUI"
HF_CACHE="${WORKSPACE_DIR}/huggingface_cache"
# Set environment variables
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
export HF_HOME="${HF_CACHE}"
# Navigate to ComfyUI directory
cd "${COMFYUI_DIR}" || exit 1
echo "Starting ComfyUI on port 8188..."
echo "Access at: http://localhost:8188"
echo "Using HuggingFace cache: ${HF_CACHE}"
# Start ComfyUI with GPU support
python3 main.py \
--listen 0.0.0.0 \
--port 8188 \
--enable-cors-header \
--preview-method auto
echo "ComfyUI stopped"

View File

@@ -17,6 +17,7 @@
# python - Python environment setup
# dependencies- Install Python packages
# models - Download AI models
# comfyui - Install and configure ComfyUI
# tailscale - Install and configure Tailscale
# systemd - Configure systemd services
# validate - Health checks and validation
@@ -63,6 +64,9 @@
- name: musicgen
port: 8003
script: models/musicgen/server.py
- name: comfyui
port: 8188
script: models/comfyui/start.sh
tasks:
#
@@ -154,6 +158,79 @@
executable: pip3
become: true
#
# ComfyUI Installation
#
- name: Install and configure ComfyUI
tags: [comfyui]
block:
- name: Check if ComfyUI is already installed
stat:
path: "{{ workspace_dir }}/ComfyUI"
register: comfyui_check
- name: Clone ComfyUI repository
git:
repo: https://github.com/comfyanonymous/ComfyUI.git
dest: "{{ workspace_dir }}/ComfyUI"
version: master
update: yes
when: not comfyui_check.stat.exists
- name: Install ComfyUI dependencies
pip:
requirements: "{{ workspace_dir }}/ComfyUI/requirements.txt"
executable: pip3
become: true
- name: Install additional ComfyUI dependencies
pip:
requirements: "{{ ai_dir }}/models/comfyui/requirements.txt"
executable: pip3
become: true
- name: Create ComfyUI models directory structure
file:
path: "{{ workspace_dir }}/ComfyUI/models/{{ item }}"
state: directory
mode: '0755'
loop:
- checkpoints
- unet
- vae
- loras
- clip
- controlnet
- name: Create symlink for Flux model in ComfyUI
file:
src: "{{ cache_dir }}"
dest: "{{ workspace_dir }}/ComfyUI/models/huggingface_cache"
state: link
ignore_errors: yes
- name: Make ComfyUI start script executable
file:
path: "{{ ai_dir }}/models/comfyui/start.sh"
mode: '0755'
- name: Display ComfyUI setup summary
debug:
msg: |
✓ ComfyUI installed successfully!
Directory: {{ workspace_dir }}/ComfyUI
Port: 8188
HuggingFace Cache: {{ cache_dir }}
To start ComfyUI:
bash {{ ai_dir }}/models/comfyui/start.sh
Or manually:
cd {{ workspace_dir }}/ComfyUI && python3 main.py --listen 0.0.0.0 --port 8188
Access: http://localhost:8188
#
# Download AI Models
#