Skip to content

Commit 5ed95c2

Browse files
authored
refactor(dev): improve Ansible ComfyUI password behavior (yondonfu#127)
This commit ensures that a unique password is generated on each run unless the user specifies a password themselves, making the deployment more secure. It allows users to provide their own password via extra-vars or environment variables while automatically generating a random password if none is provided. It also improves the ComfyUI caddy file template name.
1 parent d98e1b5 commit 5ed95c2

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.gitignore

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ __pycache__
22
*.egg-info
33
build
44
.DS_STORE
5-
comfyui*
6-
ComfyUI*
5+
comfyui/
6+
ComfyUI/
7+
cuda_temp
78

89
# VS Code settings
910
.vscode/
@@ -18,4 +19,4 @@ launch.json
1819
.env.test
1920
.env.production
2021

21-
nodes/web/static/*
22+
nodes/web/static/*

scripts/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ This repository includes an [Ansible playbook](https://docs.ansible.com/ansible/
4545
> [!IMPORTANT]
4646
> When using a non-sudo user, add `--ask-become-pass` to provide the sudo password or use an Ansible vault for secure storage.
4747

48-
7. Access the Server:
49-
Once the **Ansible playbook** completes successfully, the **ComfyStream** container will start, downloading models and building TensorRT engines. When ready, access **ComfyUI** at `https://<VM_IP>:<PORT_THAT_FORWARDS_TO_8189>`.
48+
7. **Access the Server**:
49+
After the playbook completes, **ComfyStream** will start, and you can access **ComfyUI** at `https://<VM_IP>:<PORT_FOR_8189>`. Credentials are shown in the output and regenerated each time. To persist the password, set the `comfyui_password` variable when running the playbook:
50+
51+
```bash
52+
ansible-playbook -i ansible/inventory.yaml ansible/plays/setup_comfystream.yaml -e "comfyui_password=YourSecurePasswordHere"
53+
```
5054

5155
> [!IMPORTANT]
5256
> If you encounter a `toomanyrequests` error while pulling the Docker image, either wait a few minutes or provide your Docker credentials when running the playbook:

scripts/ansible/plays/setup_comfystream.yaml

+10-7
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
vars:
66
docker_image: "livepeer/comfystream:0.0.3"
77
comfyui_username: "comfyadmin"
8-
comfyui_password: "Ge}_^jn?*?5#/|FWx9I&K|S0$/)#au8" # Set your own secure password!
98

109
tasks:
10+
# Retrieve ComfyUI server password
11+
- name: Set ComfyUI password (static if provided, random if empty)
12+
set_fact:
13+
comfyui_password: "{{ comfyui_password | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits')) }}"
1114
# Wait till VM is ready
1215
- name: Check if we can connect to the VM
1316
wait_for_connection:
@@ -126,18 +129,18 @@
126129
- /etc/caddy/certificates/selfsigned.key
127130
- /etc/caddy/certificates/selfsigned.crt
128131
notify: restart caddy
129-
- name: Create Caddy configuration for Comfystream
132+
- name: Create Caddy configuration for ComfyUI server
130133
template:
131-
src: ../../templates/comfystream.caddy.j2
132-
dest: /etc/caddy/comfystream.caddy
134+
src: ../../templates/comfyui.caddy.j2
135+
dest: /etc/caddy/comfyui.caddy
133136
owner: caddy
134137
group: caddy
135138
mode: "0644"
136139
notify: restart caddy
137-
- name: Ensure Caddyfile includes Comfystream configuration
140+
- name: Ensure Caddyfile includes ComfyUI server configuration
138141
lineinfile:
139142
path: /etc/caddy/Caddyfile
140-
line: "import /etc/caddy/comfystream.caddy"
143+
line: "import /etc/caddy/comfyui.caddy"
141144
create: yes
142145
notify: restart caddy
143146
# Ensure NVIDIA Container Toolkit is installed and configured
@@ -246,7 +249,7 @@
246249
command: "--download-models --build-engines --server"
247250
- name: Display Ansible completion message
248251
debug:
249-
msg: ComfyStream is starting up, downloading models, and building TensorRT engines—this may take a while. Access ComfyUI when ready at https://<hosturl>:<COMFYUIPort>.
252+
msg: "ComfyStream is starting up, downloading models, and building TensorRT engines—this may take a while. Access ComfyUI when ready at https://{{ ansible_default_ipv4.address }}:<COMFYUIPort>."
250253

251254
handlers:
252255
- name: restart caddy

scripts/spinup_comfystream_tensordock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"operating_system": "Ubuntu 22.04 LTS",
5353
}
5454
CADDY_TEMPLATE_PATH = os.path.join(
55-
os.path.dirname(__file__), "templates", "comfystream.caddy.j2"
55+
os.path.dirname(__file__), "templates", "comfyui.caddy.j2"
5656
)
5757
CLOUD_INIT_TEMPLATE_PATH = os.path.join(
5858
os.path.dirname(__file__), "templates", "cloud_init_comfystream.yaml.j2"
File renamed without changes.

0 commit comments

Comments
 (0)