CLI で vCenter をデプロイする

最終更新日

はじめに

vCenter のデプロイは GUI でインストールするのが一般的ですが、CLI ベースでインストールを行うこともできます。

CLI ベースのインストールでは、事前に設定を定義したjsonファイルが必要になりますが、基本的にはコマンド一発でデプロイを完了することができます

検証などで何度もvcenterをデプロイする場合は知っていて損はない内容かなと思います。

今回は最新(2022/1/1現在)のリリースである 7U3 でデプロイを行いました。

デプロイ手順

  1. ISO のダウンロード(本記事での手順紹介は省略します)
  2. テンプレートを参考にJSONファイルを作成
  3. デプロイの事前検証(任意)
  4. デプロイコマンド実行

JSON ファイルの準備

テンプレートは /vcsa-cli-installer/templates/install に存在する embedded_vCSA_on_ESXi.json を利用します。

jsonファイルの中身は以下のようになっていて、★印をつけている部分を今回は環境にあわせて変更しています。

設定値は見ていただければなんとなくわかるかと思いますが、詳細は Docs にも記載があります。1

{
    "__version": "2.13.0",
    "__comments": "Sample template to deploy a vCenter Server Appliance with an embedded Platform Services Controller on an ESXi host.",
    "new_vcsa": {
        "esxi": {
            "hostname": "<FQDN or IP address of the ESXi host on which to deploy the new appliance>"★,
            "username": "root"★,
            "password": "<Password of the ESXi host root user. If left blank, or omitted, you will be prompted to enter it at the command console during template verification.>"★,
            "deployment_network": "VM Network"★,
            "datastore": "<A specific ESXi host datastore, or a specific datastore in a datastore cluster.>"★
        },
        "appliance": {
            "__comments": [
                "You must provide the 'deployment_option' key with a value, which will affect the vCenter Server Appliance's configuration parameters, such as the vCenter Server Appliance's number of vCPUs, the memory size, the storage size, and the maximum numbers of ESXi hosts and VMs which can be managed. For a list of acceptable values, run the supported deployment sizes help, i.e. vcsa-deploy --supported-deployment-sizes"
            ],
            "thin_disk_mode": true,
            "deployment_option": "small"★,
            "name": "Embedded-vCenter-Server-Appliance"★
        },
        "network": {
            "ip_family": "ipv4",
            "mode": "static",
            "system_name": "<FQDN or IP address for the appliance. Optional when the mode is Static. Remove this if using dhcp.>"★,
            "ip": "<Static IP address. Remove this if using dhcp.>"★,
            "prefix": "<Network prefix length. Use only when the mode is 'static'. Remove if the mode is 'dhcp'. This is the number of bits set in the subnet mask; for instance, if the subnet mask is 255.255.255.0, there are 24 bits in the binary version of the subnet mask, so the prefix length is 24. If used, the values must be in the inclusive range of 0 to 32 for IPv4 and 0 to 128 for IPv6.>"★,
            "gateway": "<Gateway IP address. Remove this if using dhcp.>"★,
            "dns_servers": [
                "<DNS Server IP Address. Optional when the mode is Static. Remove this if using dhcp.>"★
            ]
        },
        "os": {
            "password": "<Appliance root password; refer to --template-help for password policy. If left blank, or omitted, you will be prompted to enter it at the command console during template verification.>"★,
            "ntp_servers": "time.nist.gov"★,
            "ssh_enable": false★
        },
        "sso": {
            "password": "<vCenter Single Sign-On administrator password; refer to --template-help for password policy. If left blank, or omitted, you will be prompted to enter it at the command console during template verification.>"★,
            "domain_name": "vsphere.local"★
        }
    },
    "ceip": {
        "description": {
            "__comments": [
                "++++VMware Customer Experience Improvement Program (CEIP)++++",
                "VMware's Customer Experience Improvement Program (CEIP) ",
                "provides VMware with information that enables VMware to ",
                "improve its products and services, to fix problems, ",
                "and to advise you on how best to deploy and use our ",
                "products. As part of CEIP, VMware collects technical ",
                "information about your organization's use of VMware ",
                "products and services on a regular basis in association ",
                "with your organization's VMware license key(s). This ",
                "information does not personally identify any individual. ",
                "",
                "Additional information regarding the data collected ",
                "through CEIP and the purposes for which it is used by ",
                "VMware is set forth in the Trust & Assurance Center at ",
                "http://www.vmware.com/trustvmware/ceip.html . If you ",
                "prefer not to participate in VMware's CEIP for this ",
                "product, you should disable CEIP by setting ",
                "'ceip_enabled': false. You may join or leave VMware's ",
                "CEIP for this product at any time. Please confirm your ",
                "acknowledgement by passing in the parameter ",
                "--acknowledge-ceip in the command line.",
                "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
            ]
        },
        "settings": {
            "ceip_enabled": true★
        }
    }
}

デプロイの事前検証

作成した JSON ファイルに入力ミスがないか、ファイルの検証を行うことができます。

実行パスは Windows Server であれば E:\vcsa-cli-installer\win32 となります。

PS E:\vcsa-cli-installer\win32> .\vcsa-deploy.exe install --verify-template-only C:\xxxx\xxx\xxx.json

特に問題がなければ実行結果でエラーは表示されません。

デプロイ実行

さあ、いよいよデプロイ実行です…!

といっても 以下のコマンドを実行するだけです。簡単でしょ?

PS E:\vcsa-cli-installer\win32> .\vcsa-deploy.exe install --accept-eula --no-ssl-certificate-verification C:\xxxx\xxx\xxx.json

ログをみてみるとだいたい25分でデプロイが完了していました。

GUI だと Stage1, Stage2 とそれぞれ手続きが必要ですが、CLI からだと一発でデプロイできるのがいいですね!

以上です!

  1. 【参考URL】https://docs.vmware.com/jp/VMware-vSphere/7.0/com.vmware.vcenter.install.doc/GUID-457EAE1F-B08A-4E64-8506-8A3FA84A0446.html#GUID-457EAE1F-B08A-4E64-8506-8A3FA84A0446