# 如何更新 XXXigCC 的 Pool URL ## 0. 版本兼容性 **重要提示**: - 支持 Ansible 2.14 及以上版本 - 已移除 `warn: false` 参数,确保兼容性 - 使用 `ansible.builtin.shell` 模块替代传统 `command` 模块 ## 1. 准备工作 在更新 XXXigCC 的 Pool URL 之前,请确保: - 已安装 Ansible 2.14 或更高版本 - 已安装 `jq` 工具 - 有权限修改 `/etc/xxxigcc/config.json` - 有权限重启 `xxxigcc-daemon.service` ## 2. 更新步骤 1. **准备变量文件**: 创建一个 `xxxigcc_update_vars.yml` 文件,包含以下关键变量: ```yaml new_pool_url: "https://new-pool.example.com" # 可选:验证旧 URL(如需) old_pool_url: "https://old-pool.example.com" ``` 2. **执行 Playbook**: ```bash ansible-playbook xxxigcc_update_pool_url.yaml -e @xxxigcc_update_vars.yml ``` ## 3. 操作说明 - Playbook 将自动备份原始配置文件 - 更新 `pools[0].url` 字段 - 清理 `/var/log/xxxigcc` 目录下的日志文件 - 重启 `xxxigcc-daemon.service` ## 4. 故障排除 - 如果更新失败,检查: 1. 变量文件格式 2. URL 地址正确性 3. 系统权限 4. Ansible 版本兼容性 ### 常见错误处理 #### Stat 模块属性访问问题 - **错误**:`'dict object' has no attribute 'isdir'` - **原因**:Ansible stat 模块返回嵌套字典结构 - **解决方案**:始终使用 `log_dir_stat.stat.isdir` 而非 `log_dir_stat.isdir` 示例修复: ```yaml - name: 检查日志目录 ansible.builtin.stat: path: "/var/log/xxxigcc" register: log_dir_stat # 正确的条件判断 - name: 处理日志目录 when: log_dir_stat.stat.exists and log_dir_stat.stat.isdir block: - name: 清理日志 # 清理操作 ``` ## 5. 安全注意事项 - 仅在可信环境中执行此 Playbook - 谨慎使用 `old_pool_url` 参数 - 确保 Ansible 版本满足最低要求 - 注意处理 stat 模块返回的嵌套字典属性