mgmt/semaphore-setup-guide.md

85 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Semaphore 项目配置指南
## 1. 访问 Semaphore Web 界面
- URL: http://your-server-ip:3000
- 用户名: `admin`
- 密码: `admin123`
## 2. 创建项目步骤
### 第一步:添加 Key Store (SSH 密钥或访问令牌)
1. 点击左侧菜单 "Key Store"
2. 点击 "New Key" 按钮
3. 填写信息:
- **Name**: `gitea-access-token`
- **Type**: 选择 "Login with password"
- **Username**: `ben`
- **Password**: `8d7d70f324796be650b79415303c31f567bf459b`
### 第二步:添加 Repository
1. 点击左侧菜单 "Repositories"
2. 点击 "New Repository" 按钮
3. 填写信息:
- **Name**: `ansible-scripts`
- **URL**: `https://gitea.tailnet-68f9.ts.net/ben/ansible-scripts.git`
- **Branch**: `main`
- **Access Key**: 选择刚创建的 `gitea-access-token`
### 第三步:创建 Inventory
1. 点击左侧菜单 "Inventory"
2. 点击 "New Inventory" 按钮
3. 填写信息:
- **Name**: `servers`
- **User Credentials**: 选择或创建服务器访问凭据
- **Sudo Credentials**: 如果需要 sudo 权限,选择相应凭据
- **Type**: 选择 "Static"
- **Inventory**: 输入服务器信息,例如:
```
[servers]
localhost ansible_connection=local
# 或添加远程服务器
# server1 ansible_host=192.168.1.10 ansible_user=root
```
### 第四步:创建 Environment
1. 点击左侧菜单 "Environment"
2. 点击 "New Environment" 按钮
3. 填写信息:
- **Name**: `production`
- **JSON**: 可以留空或添加环境变量
### 第五步:创建 Task Template
1. 点击左侧菜单 "Task Templates"
2. 点击 "New Template" 按钮
3. 填写信息:
- **Name**: `System Update`
- **Playbook**: `system-update.yml`
- **Inventory**: 选择刚创建的 `servers`
- **Repository**: 选择 `ansible-scripts`
- **Environment**: 选择 `production`
## 3. 运行任务
1. 在 "Task Templates" 页面找到 "System Update" 模板
2. 点击 "Run" 按钮
3. 确认设置后点击 "Run" 执行任务
## 4. 监控任务执行
- 在 "Tasks" 页面可以查看任务执行历史
- 点击具体任务可以查看详细日志
- 可以设置定时任务自动执行系统更新
## 项目文件说明
- `system-update.yml`: 主要的 Ansible playbook执行 apt update && apt upgrade
- `inventory.ini`: 服务器清单文件模板
- `ansible.cfg`: Ansible 配置文件
- `README.md`: 项目说明文档
## Git 仓库信息
- **仓库地址**: https://gitea.tailnet-68f9.ts.net/ben/ansible-scripts
- **分支**: main
- **最新提交**: 包含系统更新脚本的初始版本