refactor(ci): rely on ansible dynamic inventory instead of generating inventory_migration.ini
This commit is contained in:
parent
4a49c87955
commit
26c0eada57
17
.github/workflows/deploy-env-migration.yaml
vendored
17
.github/workflows/deploy-env-migration.yaml
vendored
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user