10.2. 復元プロセス
復元プロセスでは、新しいデプロイメントが作成され、filestore と SQL データベースインスタンスが、指定されたバックアップに復元されます。
- 復元には、バックアップに使用したものと同じ運用イメージバージョンを使用する必要があります。
以下の手順では、Ansible Automation Platform from GCP Marketplace デプロイメントを復元する方法を説明します。
10.2.1. ansible-on-clouds-ops コンテナーイメージのプル
手順
基盤デプロイメントと同じタグを持つ
ansible-on-clouds-opsコンテナーの Docker イメージをプルします。注記Docker イメージをプルする前に、Docker を使用して registry.redhat.io にログインしていることを確認してください。以下のコマンドを使用して registry.redhat.io にログインします。
$ docker login registry.redhat.io
レジストリーのログインに関する詳細は、Registry Authentication を参照してください。
$ export IMAGE=registry.redhat.io/ansible-on-clouds/ansible-on-clouds-ops-rhel9:2.4.20230630 $ docker pull $IMAGE --platform=linux/amd64
10.2.2. 環境の設定
手順
設定ファイルを保存するフォルダーを作成します。
$ mkdir command_generator_data
10.2.3. 必須のパーミッション
スタックを復元するには、次の GCP IAM 権限が必要です。
required-roles: Cloud SQL Client Cloud SQL Instance User Compute Instance Admin (v1) Compute Network Admin Editor Logs Writer Secret Manager Secret Accessor Service Account User required-permissions: compute.instances.list compute.networks.create deploymentmanager.deployments.create deploymentmanager.deployments.get deploymentmanager.operations.get file.instances.create file.operations.get iap.tunnelInstances.accessViaIAP secretmanager.secrets.create secretmanager.secrets.delete secretmanager.secrets.get secretmanager.secrets.update secretmanager.versions.add secretmanager.versions.list storage.objects.get storage.objects.list
10.2.4. restore.yml ファイルの生成
手順
コマンドジェネレーター
command_generator_varsを実行して、restore.ymlを生成します。注記Linux では、コマンドジェネレーターが作成したファイルまたはディレクトリーは、デフォルトで
root:rootの所有となります。ファイルとディレクトリーの所有権を変更するには、ファイルの作成後にsudo chmodコマンドを実行します。詳細は、テクニカルノート を参照してください。docker run --rm -v $(pwd)/command_generator_data:/data $IMAGE command_generator_vars gcp_restore_deployment --output-data-file /data/restore.yml
コマンドを実行すると、
$(pwd)/command_generator_data/restore.ymlテンプレートファイルが作成されます。このテンプレートファイルは以下のようになります。=============================================== Playbook: gcp_restore_deployment Description: This playbook is used to restore the Ansible Automation Platform from GCP Marketplace environment from a backup. ----------------------------------------------- This playbook is used to restore the Ansible Automation Platform from GCP Marketplace environment from a backup. For more information regarding backup and restore, visit our official documentation - https://access.redhat.com/documentation/ja-jp/ansible_on_clouds/2.x/html/red_hat_ansible_automation_platform_from_gcp_marketplace_guide/index ----------------------------------------------- Command generator template: docker run --rm -v <local_data_file_directory>:/data $IMAGE command_generator gcp_restore_deployment --data-file /data/restore.yml
テンプレートは以下のようになります。
gcp_restore_deployment: cloud_credentials_path: deployment_name: extra_vars: backup_name: gcp_bucket_backup_name: gcp_cloud_sql_peering_network: gcp_compute_region: gcp_compute_zone: gcp_controller_internal_ip_address: gcp_existing_vpc: gcp_filestore_ip_range: gcp_hub_internal_ip_address:
10.2.5. restore.yml ファイルのパラメーター
必ず新しい VPC ネットワークに復元する必要があります。
新しい VPC の場合
新しい VPC を使用して復元する場合は、以下のパラメーターを設定します。
-
gcp_existing_vpcは、falseに設定する必要があります。
以下のパラメーターを削除する必要があります。
-
gcp_filestore_ip_range -
gcp_cloud_sql_peering_network -
gcp_controller_internal_ip_address -
gcp_hub_internal_ip_address
以下のパラメーターの値を指定します。
-
gcp_existing_vpcは、falseに設定する必要があります。 -
cloud_credentials_pathは、Google Cloud サービスアカウントの認証情報ファイルのパスです。 -
deployment_nameは、デプロイメントを復元する必要がある名前です。新しいデプロイメントはこの名前で作成されます。同じ名前のデプロイメントがすでに存在していると、その名前は使用できません。 -
backup_nameはバケット内のバックアップの名前です。この名前は、gcp_backup_deploymentコマンドまたはgcp_backup_listコマンドの使用中に表示されます。 -
gcp_bucket_backup_nameは、バックアップに使用したバケットの名前です。 -
gcp_compute_regionは、バックアップが作成されたリージョンです。これは、Deployment Manager の Deployments 設定を確認することで取得できます。 -
gcp_compute_zoneは、バックアップが作成されたゾーンです。これは、Deployment Manager の Deployments 設定を確認することで取得できます。
既存の VPC の場合
既存の VPC を使用して復元する場合は、上記のパラメーターを設定する必要があります。
以下の追加パラメーターも設定する必要があります。
-
gcp_existing_vpcはtrueに設定されます。 -
gcp_filestore_ip_rangeは、VPC の空き ip/29 範囲に設定する必要があります。例: 192.168.245.0/29。192.168.243.0/29 は、Ansible Automation Platform from GCP Marketplace をデプロイするときに使用されるデフォルトであるため、使用しないでください。 -
gcp_cloud_sql_peering_networkは、空きの/24サブネットに設定する必要があります。192.168.241.0/24 は、元のデプロイメント時に使用されるため、使用しないでください。 -
gcp_controller_internal_ip_addressは、VPC ネットワーク内の空き IP に設定する必要があります。 -
gcp_hub_internal_ip_addressは、VPC ネットワーク内の空き IP に設定する必要があります。
10.2.6. 復元コマンドの実行
$(pwd)/command_generator_data/restore.yml が設定されている場合は、コマンドジェネレーターを使用して復元コマンドを作成できます。
手順
コマンドジェネレーターを実行します。
$ docker run --rm -v $(pwd)/command_generator_data:/data $IMAGE command_generator gcp_restore_deployment --data-file /data/restore.yml
これにより、必要なすべてのボリューム、環境変数、パラメーターを含む新しいコマンドが生成されます。
生成されたコマンドは以下のようになります。
docker run --rm --env PLATFORM=GCP -v <local_credential_file>:/home/runner/.gcp/credentials:ro \ --env ANSIBLE_CONFIG=../gcp-ansible.cfg --env DEPLOYMENT_NAME=<deployment_name> --env GENERATE_INVENTORY=true -\ -env CHECK_GENERATED_INVENTORY=false $IMAGE redhat.ansible_on_clouds.gcp_restore_deployment \ -e 'gcp_service_account_credentials_json_path=/home/runner/.gcp/credentials \ gcp_deployment_name=<deployment_name> gcp_compute_region=<region> gcp_compute_zone=<zone> \ gcp_bucket_backup_name=<bucket> backup_name=<backup_name> gcp_existing_vpc=<existing_vpc>'
生成されたコマンドを実行します。
$ docker run --rm --env PLATFORM=GCP -v <local_credential_file>:/home/runner/.gcp/credentials:ro \ --env ANSIBLE_CONFIG=../gcp-ansible.cfg $IMAGE redhat.ansible_on_clouds.gcp_restore_deployment \ -e 'gcp_service_account_credentials_json_path=/home/runner/.gcp/credentials \ gcp_deployment_name=<former_deployment_name> gcp_restored_deployment_name=<new_deployment_name> \ gcp_compute_region=<region> gcp_compute_zone=<zone> gcp_bucket_backup_name=<bucket> gcp_existing_vpc=False'
Playbook が完了すると、出力は以下のようになります。
TASK [redhat.ansible_on_clouds.standalone_gcp_restore : Display internal IP addresses] *** ok: [localhost] => msg: - 'Hub internal IP: 192.168.240.21' - 'Controller internal IP: 192.168.240.20' PLAY RECAP ********************************************************************* localhost : ok=33 changed=8 unreachable=0 failed=0 skipped=6 rescued=0 ignored=2
10.2.7. 復元の失敗
復元中に次のようなメッセージが表示された場合は、復元を手動で行う必要があるため、サポートに連絡する必要があります。
TASK [redhat.ansible_on_clouds.standalone_gcp_restore : [restore_deployment] Restore awx db] *
fatal: [localhost -> dvernier-restore1-aap-cntrlr-x2c6]: FAILED!