packer-cn/website/source/docs/builders/ucloud-uhost.html.md

118 lines
6.5 KiB
Markdown
Raw Normal View History

2019-06-11 08:02:00 -04:00
---
description: |
2019-06-12 02:53:00 -04:00
The `ucloud-uhost` Packer builder plugin provides the capability to build
2019-06-11 08:02:00 -04:00
customized images based on an existing base images.
layout: docs
2019-06-18 05:54:07 -04:00
page_title: 'UCloud Image Builder'
2019-06-11 08:02:00 -04:00
sidebar_current: 'docs-builders-ucloud-uhost'
---
# UCloud Image Builder
Type: `ucloud-uhost`
2019-06-12 02:53:00 -04:00
The `ucloud-uhost` Packer builder plugin provides the capability to build
2019-06-11 08:02:00 -04:00
customized images based on an existing base images.
This builder builds an UCloud image by launching an UHost instance from a source image,
provisioning that running machine, and then creating an image from that machine.
## Configuration Reference
The following configuration options are available for building UCloud images. They are
2019-06-11 08:02:00 -04:00
segmented below into two categories: required and optional parameters.
In addition to the options listed here, a
[communicator](../templates/communicator.html) can be configured for this
builder.
2019-06-28 01:58:30 -04:00
\~&gt; **Note:** The bulider doesn't support Windows images for now and only supports CentoOS and ubuntu images via SSH anthentication with `ssh_username` (Required) and `ssh_password` (Optional). The `ssh_username` must be `root` for CentOS images and `ubuntu` for Ubuntu images. The `ssh_password` may contain 8-30 characters, and must be consisted with at least 2 items out of the capital letters, lower case letters, numbers and special characters. The special characters include <code>`()~!@#$%^&*-+=_|{}\[]:;'<>,.?/</code>.
2019-06-14 02:50:46 -04:00
2019-06-11 08:02:00 -04:00
### Required:
- `public_key` - (string) This is the UCloud public key. It must be provided, but it can also be sourced from the `UCLOUD_PUBLIC_KEY` environment variable.
- `private_key` - (string) This is the UCloud private key. It must be provided, but it can also be sourced from the `UCLOUD_PRIVATE_KEY` environment variable.
- `project_id` - (string) This is the UCloud project id. It must be provided, but it can also be sourced from the `UCLOUD_PROJECT_ID` environment variables.
- `region` - (string) This is the UCloud region. It must be provided, but it can also be sourced from the `UCLOUD_REGION` environment variables.
2019-06-13 03:16:49 -04:00
- `availability_zone` - (string) This is the UCloud availability zone where UHost instance is located. such as: `cn-bj2-02`. You may refer to [list of availability_zone](https://docs.ucloud.cn/api/summary/regionlist)
2019-06-11 08:02:00 -04:00
- `instance_type` - (string) The type of UHost instance. You may refer to [list of instance type](https://docs.ucloud.cn/compute/terraform/specification/instance)
- `image_name` - (string) The name of the user-defined image, which contains 1-63 characters and only support Chinese, English, numbers, '-_,.:[]'.
2019-06-12 02:53:00 -04:00
- `source_image_id` (string) - This is the ID of base image which you want to create your customized images with.
2019-06-11 08:02:00 -04:00
### Optional:
2019-06-13 03:16:49 -04:00
- `use_ssh_private_ip` - (boolean) - If this value is true, packer will connect to the created UHost instance via a private ip instead of allocating an EIP (elastic public ip).(Default: `false`).
\~&gt; **Note:** By default (`use_ssh_private_ip` is `false`), the launched uhost instance will be connecting with extranet by bounding with an EIP (elastic public ip) automatically, which bandwidth is 30 Mb by default and paid by traffic.
2019-06-11 08:02:00 -04:00
- `internet_bandwidth` - (string) Maximum bandwidth to the EIP (elastic public ip), measured in Mbps (Mega bit per second).
2019-06-12 02:53:00 -04:00
The ranges for bandwidth are: 1-200 to pay by traffic, 1-800 to pay by bandwith. (Default: `1`).
2019-06-11 08:02:00 -04:00
- `internet_charge_mode` -(Optional) The EIP (elastic public ip) charge mode associated to UHost instance. Possible values are: `traffic` as pay by traffic, `bandwidth` as pay by bandwidth. (Default: `traffic`).
- `vpc_id` - (string) The ID of VPC linked to the UHost instance. If not defined `vpc_id`, the instance will use the default VPC in the current region.
2019-06-12 02:53:00 -04:00
- `subnet_id` - (string) The ID of subnet under VPC. If `vpc_id` is defined, the `subnet_id` is mandatory required. If `vpc_id` and `subnet_id` are not defined, the instance will use the default subnet in the current region.
2019-06-11 08:02:00 -04:00
2019-06-12 02:53:00 -04:00
- `security_group` - (string) The ID of the fire wall associated to UHost instance. If `security_group` is not defined,
the instance will use the non-recommended web fire wall, and open port include 22, 3389 by default. It is supported by ICMP fire wall protocols.
2019-06-11 08:02:00 -04:00
You may refer to [security group](https://docs.ucloud.cn/network/firewall/firewall.html).
2019-06-13 03:16:49 -04:00
- `image_description` (string) - The description of the image.
2019-06-11 08:02:00 -04:00
- `instance_name` (string) - The name of instance, which contains 1-63 characters and only support Chinese, English, numbers, '-', '_', '.'.
2019-06-12 02:53:00 -04:00
- `boot_disk_type` - (string) The type of boot disk associated to UHost instance.
2019-06-13 03:16:49 -04:00
Possible values are: `cloud_ssd` for cloud boot disk, `local_normal` and `local_ssd` for local boot disk. (Default: `cloud_ssd`).
The `cloud_ssd` and `local_ssd` are not fully supported by all regions as boot disk type, please proceed to UCloud console for more details.
\~&gt; **Note:** It takes around 10 mins for boot disk initialization when `boot_disk_type` is `local_normal` or `local_ssd`.
2019-06-11 08:02:00 -04:00
2019-06-13 03:16:49 -04:00
- `image_copy_to_mappings` (array of copied image mappings) - The array of mappings regarding the copied images to the destination regions and projects.
- `project_id` (string) - The destination project id, where copying image in.
2019-06-11 08:02:00 -04:00
2019-06-13 03:16:49 -04:00
- `region` (string) - The destination region, where copying image in.
2019-06-11 08:02:00 -04:00
2019-06-13 03:16:49 -04:00
- `name` (string) - The copied image name. If not defined, builder will use `image_name` as default name.
2019-06-11 08:02:00 -04:00
2019-06-13 03:16:49 -04:00
- `description` (number) - The copied image description.
2019-06-11 08:02:00 -04:00
## Basic Example
Here is a basic example for build UCloud image.
``` json
{
"variables": {
"ucloud_public_key": "{{env `UCLOUD_PUBLIC_KEY`}}",
2019-06-24 23:18:15 -04:00
"ucloud_private_key": "{{env `UCLOUD_PRIVATE_KEY`}}",
"ucloud_project_id": "{{env `UCLOUD_PROJECT_ID`}}"
2019-06-11 08:02:00 -04:00
},
"builders": [{
"type":"ucloud-uhost",
"public_key":"{{user `ucloud_public_key`}}",
"private_key":"{{user `ucloud_private_key`}}",
2019-06-24 23:18:15 -04:00
"project_id": "{{user `ucloud_project_id`}}",
2019-06-11 08:02:00 -04:00
"region":"cn-bj2",
2019-06-24 23:18:15 -04:00
"availability_zone": "cn-bj2-02",
2019-06-11 08:02:00 -04:00
"instance_type":"n-basic-2",
2019-06-24 23:18:15 -04:00
"source_image_id":"uimage-f1chxn",
"ssh_username":"root",
"image_name":"packer_test_{{timestamp}}"
2019-06-11 08:02:00 -04:00
}]
}
```
-&gt; **Note:** Packer can also read the public key and private key from
environmental variables. See the configuration reference in the section above
for more information on what environmental variables Packer will look for.
2019-06-12 02:53:00 -04:00
\~&gt; **Note:** Source image may be deprecated after a while, you can use the tools like `UCloud CLI` to run `ucloud image list` to find one that exists.