update ncloud guide
This commit is contained in:
parent
f044a64014
commit
56728a937b
@ -18,12 +18,12 @@ Platform](https://www.ncloud.com/).
|
||||
|
||||
### Required:
|
||||
|
||||
- `ncloud_access_key` (string) - User's access key. Go to [\[Account
|
||||
- `access_key` (string) - User's access key. Go to [\[Account
|
||||
Management > Authentication
|
||||
Key\]](https://www.ncloud.com/mypage/manage/authkey) to create and view
|
||||
your authentication key.
|
||||
|
||||
- `ncloud_secret_key` (string) - User's secret key paired with the access
|
||||
- `secret_key` (string) - User's secret key paired with the access
|
||||
key. Go to [\[Account Management > Authentication
|
||||
Key\]](https://www.ncloud.com/mypage/manage/authkey) to create and view
|
||||
your authentication key.
|
||||
@ -35,6 +35,11 @@ Platform](https://www.ncloud.com/).
|
||||
|
||||
### Optional:
|
||||
|
||||
- `vpc_no` (string) - The ID of the VPC where you want to place the Server Instance. If this field is left blank, Packer will try to get the VPC ID from the `subnet_no`.
|
||||
(You are required to least one between two parameters if u want using VPC environment: `vpc_no` or `subnet_no`)
|
||||
|
||||
- `subnet_no` (string) - The ID of the Subnet where you want to place the Server Instance. If this field is left blank, Packer will try to get the Public Subnet ID from the `vpc_no`.
|
||||
|
||||
- `member_server_image_no` (string) - Previous image code. If there is an
|
||||
image previously created, it can be used to create a new image.
|
||||
(`server_image_product_code` is required if not specified)
|
||||
@ -64,84 +69,171 @@ Platform](https://www.ncloud.com/).
|
||||
(default: Korea)
|
||||
- values: Korea / US-West / HongKong / Singapore / Japan / Germany
|
||||
|
||||
## Sample code of template.json
|
||||
## Basic Example
|
||||
|
||||
Here is a basic example for windows server.
|
||||
|
||||
{
|
||||
"variables": {
|
||||
"ncloud_access_key": "FRxhOQRNjKVMqIz3sRLY",
|
||||
"ncloud_secret_key": "xd6kTO5iNcLookBx0D8TDKmpLj2ikxqEhc06MQD2"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "ncloud",
|
||||
"access_key": "{{user `ncloud_access_key`}}",
|
||||
"secret_key": "{{user `ncloud_secret_key`}}",
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
"server_image_product_code": "SPSW0WINNTEN0016",
|
||||
"server_product_code": "SPSVRSSD00000002",
|
||||
"server_image_name": "packer-test {{timestamp}}",
|
||||
"server_image_description": "server description",
|
||||
"user_data": "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm quickconfig -q & sc config WinRM start= auto & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm get winrm/config/service\")",
|
||||
"region": "US-West",
|
||||
"communicator": "winrm",
|
||||
"winrm_username": "Administrator",
|
||||
"access_control_group_configuration_no" : 4964
|
||||
}
|
||||
```hcl
|
||||
variable "access_key" {
|
||||
type = string
|
||||
# default = "your_access_key"
|
||||
}
|
||||
|
||||
variable "secret_key" {
|
||||
type = string
|
||||
# default = "your_secret_key"
|
||||
}
|
||||
|
||||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
}
|
||||
|
||||
source "ncloud" "example-windows" {
|
||||
access_key = "${var.access_key}"
|
||||
secret_key = "${var.secret_key}"
|
||||
server_image_product_code = "SW.VSVR.OS.WND64.WND.SVR2016EN.B100" // for VPC environment.
|
||||
# server_image_product_code = "SPSW0WINNTEN0016" // for CLASSIC environment.
|
||||
server_image_name = "packer-${local.timestamp}"
|
||||
server_image_description = "server image description"
|
||||
user_data = "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm quickconfig -q & sc config WinRM start= auto & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm get winrm/config/service\")"
|
||||
region = "Korea"
|
||||
vpc_no = "{{YOUR_VPC_ID}}" // Remove this if you use CLASSIC environment.
|
||||
subnet_no = "{{YOUR_SUBNET_ID}}" // Remove this if you use CLASSIC environment.
|
||||
communicator = "winrm"
|
||||
winrm_username = "Administrator"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.ncloud.example-windows"]
|
||||
|
||||
provisioner "powershell" {
|
||||
inline = [
|
||||
"$Env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /shutdown /quiet /mode:vm \"/unattend:C:\\Program Files (x86)\\example\\nserver64.xml\" "
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"variables": {
|
||||
"ncloud_access_key": "{{env `NCLOUD_ACCESS_KEY`}}",
|
||||
"ncloud_secret_key": "{{env `NCLOUD_SECRET_KEY`}}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "ncloud",
|
||||
"access_key": "{{user `ncloud_access_key`}}",
|
||||
"secret_key": "{{user `ncloud_secret_key`}}",
|
||||
"server_image_product_code": "SPSW0WINNTEN0016",
|
||||
"server_image_name": "packer-test {{timestamp}}",
|
||||
"server_image_description": "server description",
|
||||
"user_data": "CreateObject(\"WScript.Shell\").run(\"cmd.exe /c powershell Set-ExecutionPolicy RemoteSigned & winrm quickconfig -q & sc config WinRM start= auto & winrm set winrm/config/service/auth @{Basic=\"\"true\"\"} & winrm set winrm/config/service @{AllowUnencrypted=\"\"true\"\"} & winrm get winrm/config/service\")",
|
||||
"region": "Korea",
|
||||
"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\" "
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
-> **Warning:** Please note that if you're setting up WinRM for provisioning, you'll probably want to turn it off or restrict its permissions as part of a shutdown script at the end of Packer's provisioning process. For more details on the why/how, check out this useful blog post and the associated code:
|
||||
https://cloudywindows.io/post/winrm-for-provisioning-close-the-door-on-the-way-out-eh/
|
||||
|
||||
Here is a basic example for linux server.
|
||||
|
||||
{
|
||||
"variables": {
|
||||
"ncloud_access_key": "FRxhOQRNjKVMqIz3sRLY",
|
||||
"ncloud_secret_key": "xd6kTO5iNcLookBx0D8TDKmpLj2ikxqEhc06MQD2"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "ncloud",
|
||||
"access_key": "{{user `ncloud_access_key`}}",
|
||||
"secret_key": "{{user `ncloud_secret_key`}}",
|
||||
<Tabs>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
"server_image_product_code": "SPSW0LINUX000044",
|
||||
"server_product_code": "SPSVRSSD00000002",
|
||||
"server_image_name": "packertest2",
|
||||
"server_image_description": "server image description",
|
||||
"region": "US-West",
|
||||
"communicator": "ssh",
|
||||
"ssh_username": "root"
|
||||
}
|
||||
```hcl
|
||||
variable "access_key" {
|
||||
type = string
|
||||
# default = "your_access_key"
|
||||
}
|
||||
|
||||
variable "secret_key" {
|
||||
type = string
|
||||
# default = "your_secret_key"
|
||||
}
|
||||
|
||||
locals {
|
||||
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
|
||||
}
|
||||
|
||||
source "ncloud" "example-linux" {
|
||||
access_key = "${var.access_key}"
|
||||
secret_key = "${var.secret_key}"
|
||||
server_image_product_code = "SW.VSVR.OS.LNX64.CNTOS.0708.B050" // for VPC environment.
|
||||
# server_image_product_code = "SPSW0LINUX000044" // for CLASSIC environment.
|
||||
server_image_name = "packer-${local.timestamp}"
|
||||
server_image_description = "server image description"
|
||||
region = "Korea"
|
||||
vpc_no = "{{YOUR_VPC_ID}}" // Remove this if you use CLASSIC environment.
|
||||
subnet_no = "{{YOUR_SUBNET_ID}}" // Remove this if you use CLASSIC environment.
|
||||
communicator = "ssh"
|
||||
ssh_username = "root"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["source.ncloud.example-linux"]
|
||||
|
||||
provisioner "shell" {
|
||||
inline = [
|
||||
"sleep 30", "yum install redis.x86_64 -y"
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="JSON">
|
||||
```json
|
||||
{
|
||||
"variables": {
|
||||
"ncloud_access_key": "{{env `NCLOUD_ACCESS_KEY`}}",
|
||||
"ncloud_secret_key": "{{env `NCLOUD_SECRET_KEY`}}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "ncloud",
|
||||
"access_key": "{{user `ncloud_access_key`}}",
|
||||
"secret_key": "{{user `ncloud_secret_key`}}",
|
||||
"server_image_product_code": "SPSW0LINUX000044",
|
||||
"server_image_name": "packer-test {{timestamp}}",
|
||||
"server_image_description": "server description",
|
||||
"region": "Korea",
|
||||
"communicator": "ssh",
|
||||
"ssh_username": "root"
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"sleep 30", "yum install redis.x86_64 -y"
|
||||
]
|
||||
}
|
||||
|
||||
## Requirements for creating Windows images
|
||||
|
||||
You should include the following code in the packer configuration file for
|
||||
provision when creating a Windows server.
|
||||
|
||||
"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\" "
|
||||
]
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Note
|
||||
|
||||
|
@ -34,8 +34,7 @@
|
||||
access source (0.0.0.0/0) and allowed port (5985) must be created in
|
||||
advance.
|
||||
|
||||
- `support_vpc` (bool) - Whether to use VPC. By default, the value is false on "public" site. If you want to use VPC environment. Please set this value true.
|
||||
- `vpc_no` (string) - The ID of the VPC where you want to place the Server Instance. If this field is left blank, Packer will try to get the VPC ID from the `subnet_no`.
|
||||
(You are required to least one between two parameters if u want using VPC environment: `vpc_no` or `subnet_no`)
|
||||
|
||||
- `subnet_no` (string) - The ID of the associated Subnet
|
||||
|
||||
- `vpc_no` (string) - The ID of the VPC where you want to place the Server Instance
|
||||
- `subnet_no` (string) - The ID of the Subnet where you want to place the Server Instance. If this field is left blank, Packer will try to get the Public Subnet ID from the `vpc_no`.
|
||||
|
Loading…
x
Reference in New Issue
Block a user