Packer
    • PDF

    Packer

    • PDF

    Article Summary

    Classic/VPC環境で利用できます。

    Packerは、Hashicorpが提供するサーバイメージ作成自動化ツールです。Packerを活用すると、サーバイメージを手作業で作成していた以前と違って、コマンドを入力するだけで簡単にサーバイメージを作成できます。
    Packerはプラグインの形でカスタム builderを開発しており、NAVERクラウドプラットフォーム専用のプラグインも存在します。NAVERクラウドプラットフォームのユーザーは、専用プラグインを使用してサーバイメージを簡単に作成することができます。

    参考

    Packerの実行ファイルは、Packerウェブサイトからダウンロードしてください。

    JSONテンプレート

    Packerを使用するには、コマンド実行に必要なプロパティを定義した JSONファイルが必要です。NAVERクラウドプラットフォームで使用する JSONファイルの例は、次の通りです。

    {
      "variables": {
        "ncloud_access_key": "FRxhOQRNjKVMqIz0sRLY",
        "ncloud_secret_key": "xd6kTO5iNcLookBx0D8TDKmpLj8ikxqEhc06MQD2"
      },
      "builders": [
        {
          "type": "ncloud",
          "access_key": "{{user `ncloud_access_key`}}",
          "secret_key": "{{user `ncloud_secret_key`}}",
    
          "server_image_product_code": "SPSW0LINUX000046",
          "server_product_code": "SPSVRSSD00000002",
          "server_image_name": "packertest",
          "server_image_description": "server image description",
          "region": "Korea"
        }
      ]
    }
    

    各項目の説明は、NAVERクラウドプラットフォーム用 builder ウェブページをご参照ください。

    Windowsサーバイメージの要件

    Windowsサーバイメージの作成時に必ず含めるべきコードは、次の通りです。

      "builders": [
        {
          "type": "ncloud",
          ...
          "user_data":
            "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm quickconfig -q & sc config WinRM start= auto & winrm get winrm/config/service\")",
          "communicator": "winrm",
          "winrm_username": "Administrator"
        }
      ],
      "provisioners": [
        {
          "type": "powershell",
          "inline": [
            "$Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet /mode:vm \"/unattend:C:\\Program Files (x86)\\NBP\\nserver64.xml\" "
          ]
        }
      ]
    
    注意
    • グローバル IPアドレスは、保有しているサーバインスタンス数まで作成できます。Packerを実行する前に、保有しているグローバル IPアドレスの数がサーバインスタンス数(サーバイメージの作成に使用されるものを含む)を超えないようにご注意ください。
    • Packerプロセスの強制終了、ターミナルプログラムの終了などの理由でこれ以上 Packerプロセスを進められない場合、リソースの整理ができない場合がありますので、ユーザーが手動でリソースを直接整理する必要があります。

    この記事は役に立ちましたか?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.