feat: Ansible Playbook 全栈 CRUD + 真实执行 — 替换mock为后端持久化
后端: - models/automation.go: Playbook 模型新增 Category/Tags 字段; 新增 CreatePlaybookRequest - handlers/automation.go: 新增 runPlaybookLocal(写临时YML+ansible-playbook --connection=local执行) + randomCode(crypto/rand生成唯一code) + List/Get/Create/Update/Delete/Execute Playbook 完整CRUD Execute 创建TaskExecution(task_type=playbook)记录,采集stdout/stderr/退出码/耗时 - routes/routes.go: 注册 /playbooks 路由组(7个端点) 前端: - services/api.ts: ansibleApi 从mock改为真实 /playbooks 后端调用 - AnsibleManager.tsx 完全重写: - Playbook管理: 真实数据卡片列表(id/name/category/tags/run_count/timeout) + 搜索/分类筛选 - 新建/编辑对话框复用(编辑模式预填数据) — 新增编辑入口(原无编辑功能) - 查看内容: 终端风格YAML查看器 + 快捷编辑按钮 - 执行: ConfirmProvider确认 + ansible-playbook本地执行 + toast结果反馈 - 执行记录tab: 真实TaskExecution记录(任务名/状态/开始时间/耗时/日志查看) - 统计卡片: 总数/执行中/今日成功/今日失败(基于真实执行记录) - 移除原inventory占位tab(无后端支持,避免非功能按钮) - tags JSON数组与前端string[]互转映射
This commit is contained in:
1 parent
2807e4895b
commit
ae6af93360
5 files changed
+772
-419
No files matched your search
@@ -93,6 +93,8 @@ type Playbook struct {
|
||||
Code string `gorm:"size:64;uniqueIndex;not null" json:"code"`
|
||||
Description string `gorm:"size:500" json:"description"`
|
||||
Content string `gorm:"type:text;not null" json:"content"`
|
||||
Category string `gorm:"size:64" json:"category"`
|
||||
Tags string `gorm:"type:text" json:"tags"` // JSON 数组字符串,如 ["deploy","docker"]
|
||||
Variables string `gorm:"type:text" json:"variables"`
|
||||
Inventory string `gorm:"type:text" json:"inventory"`
|
||||
Timeout int `gorm:"default:600" json:"timeout"`
|
||||
@@ -109,6 +111,18 @@ func (Playbook) TableName() string {
|
||||
return "playbooks"
|
||||
}
|
||||
|
||||
// CreatePlaybookRequest 创建Playbook请求
|
||||
type CreatePlaybookRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Description string `json:"description"`
|
||||
Content string `json:"content" binding:"required"`
|
||||
Category string `json:"category"`
|
||||
Tags string `json:"tags"` // JSON 数组字符串
|
||||
Variables string `json:"variables"`
|
||||
Inventory string `json:"inventory"`
|
||||
Timeout int `json:"timeout"`
|
||||
}
|
||||
|
||||
// CreateCronJobRequest 创建定时任务请求
|
||||
type CreateCronJobRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
|
||||
Reference in new issue
Block a user