コントロール プレーンは、 SAP Deployment Automation Framework (SDAF) のデプロイ インフラストラクチャです。 Azure で SAP 環境をプロビジョニングおよび構成するためにフレームワークが必要とするデプロイ エージェント、状態ストレージ、資格情報管理が提供されます。
コントロール プレーンがないと、SAP ワークロード ゾーンとシステムをデプロイする Terraform ワークフローと Ansible ワークフローを実行することはできません。 コントロール プレーンの設定は、フレームワークの最初の展開手順です。
この記事では、デプロイ資格情報を準備し、デプロイ元と SAP ライブラリ コンポーネントを構成し、Azure サブスクリプションにコントロール プレーン リソースを作成するスクリプトを実行します。
前提条件
- Azure のサブスクリプション。 Azure サブスクリプションをお持ちでない場合は、無料アカウントを作成してください。
- サブスクリプションのサービス プリンシパルまたはマネージド ID を作成するためのアクセス許可。
- Linux ワークステーションにインストールされている Azure CLI、または Azure DevOps へのアクセス。
デプロイ資格情報を準備する
SDAF では、デプロイにマネージド ID (推奨) またはサービス プリンシパルが使用されます。
コントロール プレーン展開の認証資格情報を作成します。 サービス プリンシパルを作成するアクセス許可を持つアカウントを使用します。
サービス プリンシパルを作成するには:
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/<subscriptionID>" --name="<environment>-Deployment-Account"マネージド ID を作成するには:
az identity create --name "<environment>-Deployment-Identity" --resource-group $ResourceGroupName --location $Location --query "{id:id, principalId:principalId, clientId:clientId}" az role assignment create --assignee-object-id <principalId> --role "Contributor" --scope /subscriptions/<subscriptionID>Important
サービス プリンシパルの名前は一意である必要があります。
コマンドの出力値を記録します。
- アプリID
- パスワード
- テナント
必要に応じて、 ユーザー アクセス管理者 ロールをサービス プリンシパルまたはマネージド ID に割り当てます。
az role assignment create --assignee <appId> --role "User Access Administrator" --scope /subscriptions/<subscriptionID>ロールのスコープを特定のリソース グループに設定するには、代わりに次のコマンドを使用します。
az role assignment create --assignee <appId> --role "User Access Administrator" --scope /subscriptions/<subscriptionID>/resourceGroups/<resourceGroupName>
コントロール プレーンのデプロイを実行する
コントロール プレーンのデプロイに必要なすべての成果物は、GitHub リポジトリにあります。 リポジトリを複製して、コントロール プレーンのデプロイを準備します。
mkdir -p ~/Azure_SAP_Automated_Deployment; cd $_
git clone https://github.com/Azure/sap-automation.git sap-automation
git clone https://github.com/Azure/sap-automation-samples.git samples
サンプルの deployer 構成ファイル
MGMT-WEEU-DEP00-INFRASTRUCTURE.tfvarsは、~/Azure_SAP_Automated_Deployment/samples/Terraform/WORKSPACES/DEPLOYER/MGMT-WEEU-DEP00-INFRASTRUCTUREフォルダーにあります。サンプルの SAP ライブラリ構成ファイル
MGMT-WEEU-SAP_LIBRARY.tfvarsは、~/Azure_SAP_Automated_Deployment/samples/Terraform/WORKSPACES/LIBRARY/MGMT-WEEU-SAP_LIBRARYフォルダーにあります。
サンプル構成ファイルをコピーして、フレームワークのテストを開始できます。
DEPLOYERの最小 Terraform ファイルは、次の例のようになります。
# The environment value is a mandatory field, it is used for partitioning the environments.
environment = "MGMT"
# The location/region value is a mandatory field, it is used to control where the resources are deployed
location = "westeurope"
# management_network_address_space is the address space for management virtual network
management_network_address_space = "10.10.20.0/25"
# management_subnet_address_prefix is the address prefix for the management subnet
management_subnet_address_prefix = "10.10.20.64/28"
# management_firewall_subnet_address_prefix is the address prefix for the firewall subnet
management_firewall_subnet_address_prefix = "10.10.20.0/26"
firewall_deployment = true
# management_bastion_subnet_address_prefix is the address prefix for the bastion subnet
management_bastion_subnet_address_prefix = "10.10.20.128/26"
bastion_deployment = true
# deployer_enable_public_ip controls if the deployer virtual machines will have Public IPs
deployer_enable_public_ip = false
# deployer_count defines how many deployer VMs will be deployed
deployer_count = 1
# use_service_endpoint defines that the management subnets have service endpoints enabled
use_service_endpoint = true
# use_private_endpoint defines that the storage accounts and key vaults have private endpoints enabled
use_private_endpoint = true
# enable_firewall_for_keyvaults_and_storage defines that the storage accounts and key vaults have firewall enabled
enable_firewall_for_keyvaults_and_storage = false
# public_network_access_enabled controls if storage account and key vaults have public network access enabled
public_network_access_enabled = false
デプロイ中の今後の編集のために、Terraform 変数ファイルの場所に注意してください。
LIBRARYの最小 Terraform ファイルは、次の例のようになります。
# The environment value is a mandatory field, it is used for partitioning the environments, for example, PROD and NP.
environment = "MGMT"
# The location/region value is a mandatory field, it is used to control where the resources are deployed
location = "westeurope"
#Defines the DNS suffix for the resources
dns_label = "azure.contoso.net"
# use_private_endpoint defines that the storage accounts and key vaults have private endpoints enabled
use_private_endpoint = true
デプロイ中の今後の編集のために、Terraform 変数ファイルの場所に注意してください。
次のコマンドを実行して、配置者と SAP ライブラリを作成します。 このコマンドは、サービス プリンシパルの詳細をデプロイ キー コンテナーに追加します。
マネージド ID の環境変数を設定します。
export ARM_SUBSCRIPTION_ID="<subscriptionId>"
export ARM_CLIENT_ID="<managedIdentityAppId>"
export ARM_TENANT_ID="<tenantId>"
サービス プリンシパルの環境変数を設定します。
export ARM_SUBSCRIPTION_ID="<subscriptionId>"
export ARM_CLIENT_ID="<appId>"
export ARM_CLIENT_SECRET="<password>"
export ARM_TENANT_ID="<tenantId>"
コントロール プレーンを展開するには、次のコマンドを実行します。
export env_code="MGMT"
export region_code="WEEU"
export vnet_code="DEP00"
export DEPLOYMENT_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/sap-automation"
export CONFIG_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/WORKSPACES"
export SAP_AUTOMATION_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/sap-automation"
az logout
az login --identity --client-id "${ARM_CLIENT_ID}"
# Uncomment next line for service principal based login
# az login --service-principal -u "${ARM_CLIENT_ID}" -p="${ARM_CLIENT_SECRET}" --tenant "${ARM_TENANT_ID}"
cd ~/Azure_SAP_Automated_Deployment/WORKSPACES
deployer_parameter_file="${CONFIG_REPO_PATH}/DEPLOYER/${env_code}-${region_code}-${vnet_code}-INFRASTRUCTURE/${env_code}-${region_code}-${vnet_code}-INFRASTRUCTURE.tfvars"
library_parameter_file="${CONFIG_REPO_PATH}/LIBRARY/${env_code}-${region_code}-SAP_LIBRARY/${env_code}-${region_code}-SAP_LIBRARY.tfvars"
#When using managed identity use:
${SAP_AUTOMATION_REPO_PATH}/deploy/scripts/deploy_controlplane.sh \
--deployer_parameter_file "${deployer_parameter_file}" \
--library_parameter_file "${library_parameter_file}" \
--subscription "${ARM_SUBSCRIPTION_ID}" \
--msi
#When using a service principal use:
${SAP_AUTOMATION_REPO_PATH}/deploy/scripts/deploy_controlplane.sh \
--deployer_parameter_file "${deployer_parameter_file}" \
--library_parameter_file "${library_parameter_file}" \
--subscription "${ARM_SUBSCRIPTION_ID}" \
--spn_id "${ARM_CLIENT_ID}" \
--spn_secret "${ARM_CLIENT_SECRET}" \
--tenant_id "${ARM_TENANT_ID}"
仮想マシンを手動で構成する
デプロイ機能に接続するには:
Azure portal にサインインする
デプロイ元の仮想マシン (VM) を含むリソース グループに移動します。
Azure Bastion を使用して VM に接続します。 既定のユーザー名は azureadm です。
[Azure Key Vault から SSH 秘密キー] を選択します。
コントロール プレーンを含むサブスクリプションを選択します。
デプロイ機能キー コンテナーを選択します。
シークレットの一覧から、 -sshkey で終わるシークレットを選択します。
VM に接続します。
配置ツールを構成するには、次のスクリプトを実行します。
mkdir -p ~/Azure_SAP_Automated_Deployment; cd $_
wget https://raw.githubusercontent.com/Azure/sap-automation/main/deploy/scripts/configure_deployer.sh -O configure_deployer.sh
chmod +x ./configure_deployer.sh
./configure_deployer.sh
# Source the new variables
./etc/profile.d/deploy_server.sh
このスクリプトでは、Terraform と Ansible がインストールされ、デプロイツールが構成されます。
コントロール プレーンをセキュリティで保護する
コントロール プレーンは、SDAF の最も重要な部分です。 外部 VM または Cloud Shell を使用してコントロール プレーンを作成した場合は、ストレージ アカウントとキー コンテナーのプライベート エンドポイントを実装してセキュリティで保護します。
deployer VM にサインインし、
sync_deployer.shスクリプトを使用してコントロール プレーン構成ファイルをコピーします。cd ~/Azure_SAP_Automated_Deployment/WORKSPACES ../sap-automation/deploy/scripts/sync_deployer.sh --storageaccountname mgtneweeutfstate### --state_subscription xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxuse_private_endpointとtrue設定ファイルでDEPLOYER変数をLIBRARYに設定します。public_network_access_enabled構成ファイルでfalseをDEPLOYERに設定します。# Defines that the storage accounts and key vaults have private endpoints enabled use_private_endpoint = true # Controls if storage account and key vaults have public network access enabled public_network_access_enabled = falseコントロール プレーンのデプロイを再実行して、ストレージ アカウントとキー コンテナーのプライベート エンドポイントを有効にします。
export env_code="MGMT" export region_code="WEEU" export vnet_code="DEP00" export storageaccountname=<storageaccountname> export DEPLOYMENT_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/sap-automation" export CONFIG_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/WORKSPACES" export SAP_AUTOMATION_REPO_PATH="${HOME}/Azure_SAP_Automated_Deployment/sap-automation" az logout az login --service-principal -u "${ARM_CLIENT_ID}" -p="${ARM_CLIENT_SECRET}" --tenant "${ARM_TENANT_ID}" cd ~/Azure_SAP_Automated_Deployment/WORKSPACES deployer_parameter_file="${CONFIG_REPO_PATH}/DEPLOYER/${env_code}-${region_code}-${vnet_code}-INFRASTRUCTURE/${env_code}-${region_code}-${vnet_code}-INFRASTRUCTURE.tfvars" library_parameter_file="${CONFIG_REPO_PATH}/LIBRARY/${env_code}-${region_code}-SAP_LIBRARY/${env_code}-${region_code}-SAP_LIBRARY.tfvars" ${SAP_AUTOMATION_REPO_PATH}/deploy/scripts/deploy_controlplane.sh \ --deployer_parameter_file "${deployer_parameter_file}" \ --library_parameter_file "${library_parameter_file}" \ --subscription "${ARM_SUBSCRIPTION_ID}" \ --spn_id "${ARM_CLIENT_ID}" \ --spn_secret "${ARM_CLIENT_SECRET}" \ --tenant_id "${ARM_TENANT_ID}" \ --storageaccountname "${storageaccountname}" \ --recover
Web アプリを準備する
このステップはオプションです。 SAP ワークロード ゾーンとシステムの構成に役立つブラウザー ベースの UI が必要な場合は、コントロール プレーンをデプロイする前に次のコマンドを実行します。
echo '[{"resourceAppId":"00000003-0000-0000-c000-000000000000","resourceAccess":[{"id":"e1fe6dd8-ba31-4d61-89e7-88639da4683d","type":"Scope"}]}]' >> manifest.json
region_code=WEEU
export TF_VAR_app_registration_app_id=$(az ad app create \
--display-name ${region_code}-webapp-registration \
--enable-id-token-issuance true \
--sign-in-audience AzureADMyOrg \
--required-resource-access @manifest.json \
--query "appId" | tr -d '"')
export TF_VAR_webapp_client_secret=$(az ad app credential reset \
--id $TF_VAR_app_registration_app_id --append \
--query "password" | tr -d '"')
export TF_VAR_use_webapp=true
rm manifest.json