From 205e591fb4b714647ede2009da19c213da5ede90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Kr=C3=BCger?= Date: Fri, 21 Nov 2025 20:41:43 +0100 Subject: [PATCH] feat: add ComfyUI integration with Ansible playbook MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- models/comfyui/requirements.txt | 12 +++++ models/comfyui/start.sh | 29 +++++++++++++ playbook.yml | 77 +++++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 models/comfyui/requirements.txt create mode 100644 models/comfyui/start.sh diff --git a/models/comfyui/requirements.txt b/models/comfyui/requirements.txt new file mode 100644 index 0000000..c6a2777 --- /dev/null +++ b/models/comfyui/requirements.txt @@ -0,0 +1,12 @@ +torch +torchvision +torchaudio +transformers +diffusers +accelerate +safetensors +omegaconf +einops +kornia +spandrel +soundfile diff --git a/models/comfyui/start.sh b/models/comfyui/start.sh new file mode 100644 index 0000000..23b8652 --- /dev/null +++ b/models/comfyui/start.sh @@ -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" diff --git a/playbook.yml b/playbook.yml index 54c8e43..ae70e7f 100644 --- a/playbook.yml +++ b/playbook.yml @@ -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 #