Packer
    • PDF

    Packer

    • PDF

    Article Summary

    Classic/VPC 환경에서 이용 가능합니다.

    Packer는 Hashicorp에서 제공하는 서버 이미지 생성 자동화 도구입니다. Packer를 활용하면 서버 이미지를 수작업으로 생성했던 이전과 달리 명령어를 입력함으로 간편하게 서버 이미지를 생성할 수 있습니다.
    Packer는 플러그인 형태로 맞춤형 builder를 개발하고 있으며, 네이버 클라우드 플랫폼 전용 플러그인도 존재합니다. 네이버 클라우드 플랫폼 사용자는 전용 플러그인을 사용하여 서버 이미지를 손쉽게 만들 수 있습니다.

    참고

    Packer 실행 파일은 Packer 웹 사이트에서 다운로드해 주십시오.

    JSON 템플릿

    Packer를 사용하려면 명령 수행에 필요한 속성을 정의한 JSON 파일이 필요합니다. 네이버 클라우드 플랫폼에서 사용하는 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"
        }
      ]
    }
    

    각 항목에 대한 설명은 네이버 클라우드 플랫폼용 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.