From 25c1fa9bd74c1049e6b9867b874de878631fe649fcf192d77e2827b9e8df503b Mon Sep 17 00:00:00 2001 From: oierxjn <1934672944@qq.com> Date: Tue, 21 Apr 2026 15:16:46 +0800 Subject: [PATCH] =?UTF-8?q?chore(ansible):=20=E5=81=9C=E6=AD=A2Git?= =?UTF-8?q?=E8=BF=BD=E8=B8=AA=E6=9C=8D=E5=8A=A1=E5=99=A8=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A4=BA=E4=BE=8B=E9=85=8D=E7=BD=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加hosts.yml和all.yml的示例配置文件 更新README.md中的部署说明 将敏感配置文件添加到.gitignore --- .gitignore | 4 ++ README.md | 10 ++++- ansible/inventory/group_vars/all.yml.example | 42 ++++++++++++++++++++ ansible/inventory/hosts.yml.example | 7 ++++ 4 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 ansible/inventory/group_vars/all.yml.example create mode 100644 ansible/inventory/hosts.yml.example diff --git a/.gitignore b/.gitignore index 29e61d4..120ced4 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ Thumbs.db # OpenCode .opencode/ + +# Server inventory +ansible/inventory/hosts.yml +ansible/inventory/group_vars/all.yml diff --git a/README.md b/README.md index 23e0cc2..1bf0d8d 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,14 @@ tjhlp-gitea/ ```bash cd ansible -# 编辑 inventory/hosts.yml 填入服务器地址 -# 编辑 inventory/group_vars/all.yml 修改域名、密码等 +cp inventory/hosts.yml.example inventory/hosts.yml +cp inventory/group_vars/all.yml.example inventory/group_vars/all.yml +``` + +编辑 ansible/inventory/hosts.yml 填入服务器地址 +编辑 ansible/inventory/group_vars/all.yml 修改域名、密码等 + +```bash ansible-playbook playbook.yml ``` diff --git a/ansible/inventory/group_vars/all.yml.example b/ansible/inventory/group_vars/all.yml.example new file mode 100644 index 0000000..ccfd136 --- /dev/null +++ b/ansible/inventory/group_vars/all.yml.example @@ -0,0 +1,42 @@ +--- +# ============================================================================= +# Gitea 答疑平台部署变量 +# ============================================================================= + +# ----------------------------------------------------------------------------- +# Gitea 基础配置 +# ----------------------------------------------------------------------------- +# 留空则自动获取最新版本, 填写则使用指定版本(如 "1.25.1") +gitea_version: "" + +gitea_http_port: 3000 +gitea_domain: "gitea.example.com" # 替换为实际域名或 IP +gitea_app_name: "同济大学高级语言程序设计答疑平台" + +# ----------------------------------------------------------------------------- +# Gitea 管理员账号(首次部署自动创建, 部署后请修改密码) +# ----------------------------------------------------------------------------- +gitea_admin_user: "admin" +gitea_admin_password: "ChangeMe!2026" # 部署后务必修改 +gitea_admin_email: "shenjian@tongji.edu.cn" + +# ----------------------------------------------------------------------------- +# PostgreSQL 数据库配置 +# ----------------------------------------------------------------------------- +postgresql_version: 18 +gitea_db_name: "gitea" +gitea_db_user: "gitea" +gitea_db_password: "change_this_db_password" # 请修改为强密码 + +# ----------------------------------------------------------------------------- +# Webhook 配置 +# ----------------------------------------------------------------------------- +gitea_webhook_allowed_hosts: "*" +gitea_webhook_skip_tls: "false" + +# ----------------------------------------------------------------------------- +# 安全密钥(留空则自动生成, 生成后建议记录保存) +# ----------------------------------------------------------------------------- +gitea_secret_key: "" +gitea_internal_token: "" +gitea_lfs_jwt_secret: "" diff --git a/ansible/inventory/hosts.yml.example b/ansible/inventory/hosts.yml.example new file mode 100644 index 0000000..1569faf --- /dev/null +++ b/ansible/inventory/hosts.yml.example @@ -0,0 +1,7 @@ +--- +all: + hosts: + gitea-server: + ansible_host: 192.168.1.100 # 替换为实际服务器 IP + ansible_user: root # 替换为实际 SSH 用户 + # ansible_ssh_private_key_file: ~/.ssh/id_rsa