LoginSignup
0
0

More than 1 year has passed since last update.

【Equinix Metal/BMaaS】vSphere/vSAN環境をTerraformで一撃デプロイ②

Last updated at Posted at 2021-11-15

VMwareのSDS(Software Defined Storage)ソリューションであるvSANで構成されたvSphereクラスタを、Equinix MetalのBMaaS(Baremetal as a Service)に構築してみました。

Terraformを利用する事で、約1時間でvSAN構成のvSphereクラスタを一撃デプロイできます。
vSAN、Equinix Metalについては以下リンクを参照ください。

VMware Virtual SAN 入門: 〜 従来のストレージと VSAN の違い〜

Equinix Metal

====

====

参考資料

Equinix MetalがメンテしているGithubリポジトリ。こちらを元に作業を進めます。
https://github.com/equinix/terraform-metal-vsphere

環境構成図

image.png

赤点線の範囲がTerraformにより構築される部分です。
今回は前回準備したTerraformモジュールのパラメータ編集を行っていきます。

前回準備したファイルの確認

リポジトリからクローンした、Terraformモジュールのフォルダへ移動します。
以下構成のディレクトリが存在することを確認しましょう。

$ cd terraform-metal-vsphere
$ tree                              
.
├── LICENSE
├── README.md
├── main.tf
├── outputs.tf
├── scripts 
│   └── get_vcenter_ip.py
├── templates 
│   ├── deploy_vcva.py
│   ├── download_vcenter.sh
│   ├── esx_host_networking.py
│   ├── extend_datastore.sh
│   ├── l2tp_vpn.sh
│   ├── pre_reqs.py
│   ├── update_uplinks.py
│   ├── vcva_template.json
│   └── vsan_claim.py
├── variables.tf
└── versions.tf

4. デプロイ用の変数ファイル(variables.tf)を修正する

変数ファイルの設定値を変更していきます。
事前準備で構築したMinIO用サーバ関連の設定値、vCenter用ISOファイル名等を設定します。

初期値の場合、自動でプロジェクトが新規作成されてしまうので、既存プロジェクト内にデプロイしたい場合は以下辺りの設定値を変更してください。今回は既存プロジェクト内にデプロイする前提で作成します。

プロジェクトから新規作成する場合は、organization_idを設定してください。
他、ドメイン名やホスト名も必要に応じて調整してみてください。

$ vi variables.tf

variable "auth_token" {
  description = "This is your Equinix Metal API Auth token"
  sensitive   = true
  type        = string
  default     = "xxxxxxxxxxxxxxx" ←★Metalポータルで発行したAPIトークン
}

variable "organization_id" {
  description = "Your Equinix Metal Organization Id"
  default     = "null"  ←★[project作成時のみ]projectを作成する親組織のIDを設定
  type        = string
}

variable "create_project" {
  description = "if true create the Equinix Metal project, if not skip and use the provided project"
  default     = false  ★←project作成しない場合はfalse
}

variable "project_id" {
  description = "Equinix Metal Project ID to use in case create_project is false"
  default     = "xxxxxxxxxxxxxxx" ←★既存projectを利用する場合は、project IDを入力する
}

《中略》

variable "facility" {
  description = "This is the Region/Location of your deployment."
  default     = "sg1" ←★データセンターをsg1に設定
}

《中略》

variable "s3_url" {
  description = "This is the URL endpoint to connect your s3 client to"
  default     = "http://[MinIOサーバのグローバルIP]:9000" ←★前回作成したMinIOのアクセスURL
}

variable "s3_access_key" {
  description = "This is the access key for your S3 endpoint"
  sensitive   = true
  default     = "minio" ←★前回作成したMinIOのアクセスキー
}

variable "s3_secret_key" {
  description = "This is the secret key for your S3 endpoint"
  sensitive   = true
  default     = "miniostorage" ←★前回作成したMinIOのシークレットキー

《中略》

variable "vcenter_iso_name" {
  description = "The name of the vCenter ISO in your Object Store"
  type        = string
  default     = "VMware-VCSA-all-7.0.1-17491101.iso" ←★MinIOに配置したvCenter用ISOファイル
}

5. (任意)outputs.tfファイルのsensitiveパラメータ設定調整

デプロイ完了後に出力されるPW等がsensitiveパラメータに設定されているため、初期状態のままでは表示されません。
PWはデプロイ後に作成されるterraform.tfstateファイルに書いてありますが、検索が面倒な方は必要に応じてsensitive設定を解除(コメントアウト)してください。

[一括コメントアウトするコマンド]
$ sed -ie "s/  sensitive/\/\/  sensitive/g" outputs.tf 

[個別編集個所はこちら]
$ vi outputs.tf 

《中略》

output "vpn_psk" {
  value       = random_string.ipsec_psk.result
//  sensitive   = true ←★コメントアウト
  description = "L2TP VPN Pre-Shared Key"
}

《中略》

output "vpn_password" {
  value       = random_string.vpn_pass.result
//  sensitive   = true ←★コメントアウト
  description = "L2TP VPN Password"
}

《中略》

output "vcenter_password" {
  value       = random_string.sso_password.result
//  sensitive   = true ←★コメントアウト
  description = "The SSO Password to login to vCenter"
}

output "vcenter_root_password" {
  value       = random_string.vcenter_password.result
//  sensitive   = true ←★コメントアウト
  description = "The root password to ssh or login at the console of vCanter."
}

6. terraform init/plan の実行

initコマンドでTerraformプロジェクトの初期化、planでプロジェクトの検証を行います。
エラーのような文言が出た場合は出力内容に応じて調整してください。エラーが出なければ問題ありません。

$ terraform init

《中略》

Partner and community providers are signed by their developers.
If you'd like to know more about provider signing, you can read about it here:
https://www.terraform.io/docs/plugins/signing.html

Terraform has been successfully initialized! ←★init 成功時の出力

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary. 


$ terraform plan 

《中略》

Plan: 49 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + bastion_host          = (known after apply)
  + ssh_key_path          = "$HOME/.ssh/vmware-on-metal-1-kyhgz-key"
  + vcenter_fqdn          = "vcva.metal.local"
  + vcenter_ip            = (known after apply)
  + vcenter_password      = (known after apply)
  + vcenter_root_password = (known after apply)
  + vcenter_username      = "Administrator@vsphere.local"
  + vpn_endpoint          = (known after apply)
  + vpn_password          = (known after apply)
  + vpn_psk               = (known after apply)
  + vpn_user              = "vm_admin"

------------------------------------------------------------------------

Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.

準備作業は以上になります。

次回はterraformデプロイ実行と、デプロイした環境へのアクセスを試していきます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0