本部分生成企业级 AI Application Platform 自动化部署 Ansible Role
目标:
建设企业私有化 AI 应用平台,实现:
- 企业 ChatGPT
- RAG 知识库
- AI Agent
- Workflow 编排
- MCP Tool Calling
- 多模型统一接入
- Prompt 管理
- LLM Gateway
- AI 应用监控
- 企业知识助手
适用于:
Ubuntu 22.04 / 24.04
Docker
Kubernetes
GPU Server
NVIDIA CUDA
vLLM
Triton
OpenAI Compatible API
Ansible >=2.15
15.35.1 AI Application Platform架构
User
|
Web / Mobile
|
API Gateway
|
+------------+------------+
| |
AI Gateway Auth
|
+-------+----------------+
| |
Agent RAG Engine
| |
+-----+-----+ +-----+------+
| | | |
MCP Tools Vector DB Knowledge
|
LLM Runtime
|
+-------------+--------------+
| | |
vLLM Triton Ollama
|
GPU Cluster
15.35.2 Role目录结构
创建:
roles/ai-application-platform/
├── defaults/
│ └── main.yml
├── tasks/
│ ├── main.yml
│ ├── docker.yml
│ ├── llm-gateway.yml
│ ├── dify.yml
│ ├── fastgpt.yml
│ ├── flowise.yml
│ ├── langflow.yml
│ ├── anythingllm.yml
│ ├── openwebui.yml
│ ├── rag.yml
│ ├── vector-db.yml
│ ├── agent.yml
│ ├── mcp.yml
│ ├── workflow.yml
│ ├── prompt.yml
│ ├── auth.yml
│ └── monitoring.yml
├── templates/
│
│ ├── docker-compose.yml.j2
│ ├── dify-compose.yml.j2
│ ├── fastgpt-compose.yml.j2
│ ├── openwebui-compose.yml.j2
│ ├── qdrant-compose.yml.j2
│ ├── pgvector.yml.j2
│ ├── llm-gateway.yaml.j2
│ ├── mcp-server.yaml.j2
│ ├── prometheus.yml.j2
│ └── alert.rules.j2
└── handlers/
└── main.yml
15.35.3 默认变量
文件:
roles/ai-application-platform/defaults/main.yml
---
ai_app_root:
/mnt/ai-app
#####################
# Platform
#####################
enable_dify:
true
enable_fastgpt:
true
enable_flowise:
true
enable_langflow:
true
enable_openwebui:
true
#####################
# Vector Database
#####################
vector_database:
qdrant
enable_pgvector:
true
#####################
# LLM Backend
#####################
llm_api_mode:
openai-compatible
llm_endpoint:
http://vllm:8000/v1
#####################
# Authentication
#####################
enable_keycloak:
true
#####################
# Monitoring
#####################
enable_prometheus:
true
15.35.4 Inventory
文件:
inventory/production/ai-app.yml
---
ai_application:
children:
ai_nodes:
hosts:
ai-app01:
ansible_host:
10.10.120.10
ai-app02:
ansible_host:
10.10.120.11
15.35.5 Playbook
文件:
playbooks/ai-application.yml
---
- name:
Deploy AI Application Platform
hosts:
ai_application
become:
true
roles:
- ai-application-platform
15.35.6 Role入口
tasks/main.yml
---
- import_tasks:
docker.yml
- import_tasks:
vector-db.yml
- import_tasks:
llm-gateway.yml
- import_tasks:
dify.yml
- import_tasks:
fastgpt.yml
- import_tasks:
flowise.yml
- import_tasks:
langflow.yml
- import_tasks:
anythingllm.yml
- import_tasks:
openwebui.yml
- import_tasks:
rag.yml
- import_tasks:
agent.yml
- import_tasks:
mcp.yml
- import_tasks:
workflow.yml
- import_tasks:
prompt.yml
- import_tasks:
auth.yml
- import_tasks:
monitoring.yml
15.35.7 Docker环境
tasks/docker.yml
---
- name:
install docker
apt:
name:
- docker.io
- docker-compose-plugin
state:
present
- name:
enable docker
service:
name:
docker
state:
started
enabled:
true
15.35.8 Vector Database层
支持:
- Qdrant
- Milvus
- Chroma
- PGVector
Qdrant
templates/qdrant-compose.yml.j2
services:
qdrant:
image:
qdrant/qdrant
ports:
- 6333:6333
volumes:
- /mnt/vector:/qdrant/storage
启动:
docker compose up -d
测试:
curl localhost:6333
PGVector
services:
postgres:
image:
pgvector/pgvector
environment:
POSTGRES_DB:
vector
15.35.9 LLM Gateway
作用:
统一管理:
OpenAI API
Azure OpenAI
vLLM
Ollama
Claude
Gemini
Qwen
DeepSeek
架构:
Client
|
LLM Gateway
|
+--------+---------+
| | |
vLLM OpenAI Ollama
配置:
providers:
vllm:
endpoint:
http://vllm:8000/v1
openai:
endpoint:
https://api.openai.com/v1
API:
curl:
http://gateway/v1/chat/completions
15.35.10 Dify
企业AI应用平台。
功能:
- Workflow
- Agent
- RAG
- Knowledge Base
部署:
templates/dify-compose.yml.j2
services:
api:
image:
langgenius/dify-api
web:
image:
langgenius/dify-web
db:
image:
postgres:15
redis:
image:
redis:7
启动:
docker compose up -d
访问:
https://dify.company.com
15.35.11 FastGPT
国产知识库平台
架构:
User
|
FastGPT
|
MongoDB
|
Vector DB
|
LLM
部署:
services:
fastgpt:
image:
ghcr.io/labring/fastgpt
mongodb:
image:
mongo:7
能力:
知识库
Agent
工作流
插件
函数调用
15.35.12 Flowise
Low Code Agent
部署:
services:
flowise:
image:
flowiseai/flowise
ports:
- 3000:3000
访问:
http://flowise.company.com
支持:
- LangChain
- Agent
- RAG
15.35.13 LangFlow
可视化AI流程
部署:
services:
langflow:
image:
langflowai/langflow
流程:
Input
|
Retriever
|
LLM
|
Output
15.35.14 AnythingLLM
私有ChatGPT
部署:
services:
anythingllm:
image:
mintplexlabs/anythingllm
支持:
- 本地模型
- 文档问答
- RAG
15.35.15 OpenWebUI
ChatGPT Web界面
部署:
services:
open-webui:
image:
ghcr.io/open-webui/open-webui
ports:
- 3000:8080
连接:
OpenWebUI
|
vLLM
|
Qwen/Llama/DeepSeek
15.35.16 RAG Service
架构:
Document
|
Embedding
|
Vector DB
|
Retriever
|
LLM
|
Answer
组件:
Embedding:
BGE
E5
OpenAI embedding
Vector:
Qdrant
Milvus
PGVector
15.35.17 Agent Platform
支持:
- LangChain Agent
- AutoGen
- CrewAI
架构:
User
|
Agent
|
Planner
|
Tool
|
LLM
示例:
agent.run(
"查询数据库"
)
15.35.18 MCP Server
Model Context Protocol
架构:
LLM
|
MCP Client
|
MCP Server
|
Tool
目录:
mcp/
├── filesystem
├── database
├── kubernetes
├── git
└── api
部署:
services:
mcp-server:
image:
mcp/server
15.35.19 Workflow Engine
支持:
- Dify Workflow
- LangFlow
- n8n
部署:
services:
n8n:
image:
n8nio/n8n
流程:
Trigger
|
AI Node
|
Tool Node
|
Human Approval
|
Output
15.35.20 Prompt Management
平台:
- Langfuse
- PromptLayer
Langfuse:
services:
langfuse:
image:
langfuse/langfuse
管理:
Prompt Version
Token Cost
Experiment
A/B Test
15.35.21 Authentication
集成:
- Keycloak
- LDAP
- OAuth2
配置:
auth:
provider:
keycloak
url:
https://keycloak.company.com
支持:
SSO
RBAC
MFA
OIDC
15.35.22 AI Monitoring
监控:
Application
|
Prometheus
|
Grafana
|
Alertmanager
指标:
Request Count
Latency
Token Usage
GPU Usage
Model Load
RAG Accuracy
15.35.23 Prometheus规则
alert.rules.j2
groups:
- name:
ai-platform
rules:
- alert:
LLMHighLatency
expr:
llm_latency_seconds > 5
for:
5m
15.35.24 健康检查
scripts/check-ai-app.sh
#!/bin/bash
echo Vector DB
curl localhost:6333
echo OpenWebUI
curl localhost:3000
echo Dify
curl localhost
echo LLM API
curl localhost:8000/v1/models
15.35.25 自动部署
执行:
ansible-playbook \
-i inventory/production \
playbooks/ai-application.yml
验证:
OpenWebUI
https://chat.company.com
Dify
https://dify.company.com
FastGPT
https://fastgpt.company.com
Flowise
https://flowise.company.com
Part 15.35完成
✅ Dify
✅ FastGPT
✅ Flowise
✅ LangFlow
✅ AnythingLLM
✅ OpenWebUI
✅ Qdrant
✅ PGVector
✅ LLM Gateway
✅ RAG Service
✅ Agent Platform
✅ MCP Server
✅ Workflow Engine
✅ Prompt Management
✅ Langfuse
✅ Keycloak SSO
✅ LDAP Integration
✅ AI Monitoring
✅ Prometheus
✅ Grafana
✅ Alertmanager
110




被折叠的 条评论
为什么被折叠?



