Automated Flowise deployment using Ansible and Docker Compose.
- name: Deploy Flowise
hosts: flowise
become: true
vars:
flowise_version: "latest"
app_root: /opt/flowise
flowise_port: 3000
# Database configuration
database_type: "sqlite"
database_path: "/opt/flowise/data/database.sqlite"
# Optional: PostgreSQL
postgres_password: "{{ lookup('password', '/dev/null chars=ascii_letters,digits length=16') }}"
# Optional: Authentication
basic_auth_username: ""
basic_auth_password: ""
# Optional: Redis
redis_enabled: false
redis_password: "{{ lookup('password', '/dev/null chars=ascii_letters,digits length=16') }}"
tasks:
- name: Install Docker on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Docker on RHEL family
dnf:
name:
- docker
- docker-compose-plugin
- git
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create app directory
file:
path: "{{ app_root }}"
state: directory
mode: "0755"
- name: Create data directories
file:
path: "{{ item }}"
state: directory
mode: "0755"
loop:
- "{{ app_root }}/data"
- "{{ app_root }}/storage"
- name: Clone Flowise repository
git:
repo: https://github.com/FlowiseAI/Flowise.git
dest: "{{ app_root }}/Flowise"
version: master
depth: 1
- name: Create docker-compose.yml
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
version: '3.8'
services:
flowise:
image: flowise/flowise:{{ flowise_version }}
container_name: flowise
restart: always
ports:
- "{{ flowise_port }}:3000"
volumes:
- ./data:/root/.flowise
environment:
- PORT=3000
- DATABASE_TYPE={{ database_type }}
{% if database_type == 'sqlite' %}
- DATABASE_PATH={{ database_path }}
{% endif %}
{% if basic_auth_username %}
- BASIC_AUTH_USERNAME={{ basic_auth_username }}
- BASIC_AUTH_PASSWORD={{ basic_auth_password }}
{% endif %}
networks:
- flowise-network
networks:
flowise-network:
driver: bridge
- name: Start Flowise stack
command: docker compose up -d
args:
chdir: "{{ app_root }}"
- name: Wait for Flowise to be ready
wait_for:
port: "{{ flowise_port }}"
delay: 5
timeout: 300
- name: Display setup information
debug:
msg: |
Flowise has been deployed!
ACCESS:
- URL: http://{{ ansible_host | default(inventory_hostname) }}:{{ flowise_port }}
DATA LOCATION:
- {{ app_root }}/data
- {{ app_root }}/storage
COMMANDS:
- View logs: cd {{ app_root }} && docker compose logs -f
- Stop: cd {{ app_root }} && docker compose down
- Restart: cd {{ app_root }} && docker compose restart
Repository: https://github.com/FlowiseAI/Flowise
Documentation: https://docs.flowiseai.com
ansible-playbook -i inventory.ini flowise.yml
ansible-playbook -i inventory.ini flowise.yml \
-e "flowise_port=3001" \
-e "basic_auth_username=admin" \
-e "basic_auth_password=secure-password"
Create flowise_vars.yml:
flowise_version: "latest"
flowise_port: 3000
basic_auth_username: "admin"
basic_auth_password: "secure-password"
database_type: "sqlite"
Run:
ansible-playbook -i inventory.ini flowise.yml -e "@flowise_vars.yml"
- name: Deploy Flowise with PostgreSQL
hosts: flowise
become: true
vars:
app_root: /opt/flowise
flowise_port: 3000
postgres_password: "{{ lookup('password', '/dev/null chars=ascii_letters,digits length=16') }}"
tasks:
- name: Install Docker
apt:
name:
- docker.io
- docker-compose-plugin
- git
state: present
when: ansible_os_family == "Debian"
- name: Create app directory
file:
path: "{{ app_root }}"
state: directory
- name: Create docker-compose.yml with PostgreSQL
copy:
dest: "{{ app_root }}/docker-compose.yml"
mode: "0644"
content: |
version: '3.8'
services:
flowise:
image: flowise/flowise:latest
container_name: flowise
restart: always
ports:
- "{{ flowise_port }}:3000"
volumes:
- ./data:/root/.flowise
environment:
- DATABASE_TYPE=postgres
- DATABASE_HOST=postgres
- DATABASE_PORT=5432
- DATABASE_NAME=flowise
- DATABASE_USER=flowise
- DATABASE_PASSWORD={{ postgres_password }}
depends_on:
postgres:
condition: service_healthy
networks:
- flowise-network
postgres:
image: postgres:15-alpine
container_name: flowise-postgres
restart: always
volumes:
- ./postgres-data:/var/lib/postgresql/data
environment:
- POSTGRES_DB=flowise
- POSTGRES_USER=flowise
- POSTGRES_PASSWORD={{ postgres_password }}
networks:
- flowise-network
healthcheck:
test: ["CMD-SHELL", "pg_isready -U flowise"]
interval: 30s
timeout: 10s
retries: 3
networks:
flowise-network:
driver: bridge
- name: Start Flowise stack
command: docker compose up -d
args:
chdir: "{{ app_root }}"
- name: Backup Flowise
hosts: flowise
become: true
vars:
app_root: /opt/flowise
backup_dir: /backup/flowise
tasks:
- name: Create backup directory
file:
path: "{{ backup_dir }}"
state: directory
mode: "0700"
- name: Backup Flowise data
archive:
path:
- "{{ app_root }}/data"
- "{{ app_root }}/storage"
dest: "{{ backup_dir }}/flowise-data-{{ ansible_date_time.date }}.tar.gz"
- name: Backup docker-compose.yml
copy:
src: "{{ app_root }}/docker-compose.yml"
dest: "{{ backup_dir }}/docker-compose.yml"
remote_src: yes
- name: Upgrade Flowise
hosts: flowise
become: true
vars:
app_root: /opt/flowise
tasks:
- name: Backup before upgrade
include_tasks: backup.yml
- name: Pull latest image
command: docker compose pull flowise
args:
chdir: "{{ app_root }}"
- name: Restart Flowise
command: docker compose up -d flowise
args:
chdir: "{{ app_root }}"
- name: Wait for Flowise to be ready
wait_for:
port: 3000
delay: 5
timeout: 300
Any questions?
Feel free to contact us. Find all contact information on our contact page.