From 26c0eada57c552f746000c1b54a9a46e69b0086d Mon Sep 17 00:00:00 2001 From: Haitao Pan Date: Wed, 1 Jul 2026 09:43:19 +0800 Subject: [PATCH] refactor(ci): rely on ansible dynamic inventory instead of generating inventory_migration.ini --- .github/workflows/deploy-env-migration.yaml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/deploy-env-migration.yaml b/.github/workflows/deploy-env-migration.yaml index 7ad00c7..e99f8b8 100644 --- a/.github/workflows/deploy-env-migration.yaml +++ b/.github/workflows/deploy-env-migration.yaml @@ -292,25 +292,10 @@ jobs: printf '%s' "${{ steps.vault.outputs.ANSIBLE_SSH_KEY_B64 }}" | base64 -d > ~/.ssh/id_deploy chmod 600 ~/.ssh/id_deploy - - name: Generate Migration Inventory - run: | - # 动态解析 target IP,如果是纯数据迁移,则可能需要手动指定,这里以 jq 解析 cmdb 为主 - if [ -f "cmdb/cmdb.json" ]; then - TARGET_IP=$(jq -r 'to_entries | .[0].value.ip' cmdb/cmdb.json) - else - TARGET_IP="new_env_ip_placeholder" # 需要补充处理纯迁移模式下的 Target IP - fi - - echo "[migration_source]" > inventory_migration.ini - echo "${{ github.event.inputs.source_host }} ansible_user=root ansible_ssh_private_key_file=~/.ssh/id_deploy" >> inventory_migration.ini - echo "" >> inventory_migration.ini - echo "[migration_target]" >> inventory_migration.ini - echo "${TARGET_IP} ansible_user=root ansible_ssh_private_key_file=~/.ssh/id_deploy" >> inventory_migration.ini - - name: Run Toolkit Action (${{ github.event.inputs.toolkit_action }}) working-directory: site-migration-toolkit run: | - make ${{ github.event.inputs.toolkit_action }} RUN_ARGS="-i $GITHUB_WORKSPACE/inventory_migration.ini -e target_domain=${{ github.event.inputs.target_domain_base }} -e migration_flow.source.domain_base=${{ github.event.inputs.source_domain_base }}" + make ${{ github.event.inputs.toolkit_action }} RUN_ARGS="-e source_host=${{ github.event.inputs.source_host }} -e target_domain=${{ github.event.inputs.target_domain_base }} -e migration_flow.source.domain_base=${{ github.event.inputs.source_domain_base }}" switch_dns: name: Switch DNS Traffic (Manual Approval)