hashicorp / packer-plugin-tencentcloud Goto Github PK
View Code? Open in Web Editor NEWPacker plugin for Tencent Cloud Image Builder
Home Page: https://www.packer.io/docs/builders/tencentcloud-cvm
License: Mozilla Public License 2.0
Packer plugin for Tencent Cloud Image Builder
Home Page: https://www.packer.io/docs/builders/tencentcloud-cvm
License: Mozilla Public License 2.0
I used Packer to build the image and it errored out after 10 min.
Version 1.7.6
tencentcloud-cvm.testPacker_DS_config: output will be in this color.
==> tencentcloud-cvm.testPacker_DS_config: Trying to check image name: PackerTest_dsConfig...
tencentcloud-cvm.testPacker_DS_config: Image name: useable
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepPreValidate'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Trying to check source image: ***...
tencentcloud-cvm.testPacker_DS_config: Image found: Tencent Linux Release 2.2 (Final)
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepCheckSourceImage'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Not to use temporary keypair
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepConfigKeyPair'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Trying to use existing vpc: ***...
tencentcloud-cvm.testPacker_DS_config: Vpc found: ****
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepConfigVPC'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Trying to use existing subnet: ***..
tencentcloud-cvm.testPacker_DS_config: Subnet found: ***
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepConfigSubnet'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Trying to use existing securitygroup: ***...
tencentcloud-cvm.testPacker_DS_config: Securitygroup found: ***
==> tencentcloud-cvm.testPacker_DS_config: Pausing after run of step 'stepConfigSecurityGroup'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Trying to create a new instance...
==> tencentcloud-cvm.testPacker_DS_config: Failed to run instance: [TencentCloudSDKError] Code=InvalidPermission, Message=Bandwidth package user does not support the value `TRAFFIC_POSTPAID_BY_HOUR` in the parameter `.InternetAccessible.InternetChargeType`, RequestId=0e97cc45-2dd5-4de4-849d-e338570ed77a
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepConfigSecurityGroup'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepConfigSubnet'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepConfigVPC'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepConfigKeyPair'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepCheckSourceImage'. Press enter to continue.
==> tencentcloud-cvm.testPacker_DS_config: Pausing before cleanup of step 'stepPreValidate'. Press enter to continue.
Build 'tencentcloud-cvm.testPacker_DS_config' errored after 9 minutes 58 seconds: [TencentCloudSDKError] Code=InvalidPermission, Message=Bandwidth package user does not support the value `TRAFFIC_POSTPAID_BY_HOUR` in the parameter `.InternetAccessible.InternetChargeType`, RequestId=0e97cc45-2dd5-4de4-849d-e338570ed77a
This issue was originally opened by @jianzhiteh as hashicorp/packer#10682. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
We try to query source_image_name
by passing in the custom image name we want to create our new image from, but the build seems failed with error below:
Reference - Feature Request: hashicorp/packer#9548
❯ packer build tencentcloud-cfs.json
tencentcloud-cvm: output will be in this color.
==> tencentcloud-cvm: Trying to check image name: our-image-name...
tencentcloud-cvm: Image name: useable
==> tencentcloud-cvm: Trying to check source image: ...
==> tencentcloud-cvm: No image found under current instance_type(S2.MEDIUM4) restriction
Build 'tencentcloud-cvm' errored after 2 seconds 239 milliseconds: No image found under current instance_type(S2.MEDIUM4) restriction
Steps to reproduce this issue
packer build
1.7.0
"source_image_name": "our-source-image-name",
tencentcloud-cvm: output will be in this color.
2021/02/23 15:51:26 Force build: false
2021/02/23 15:51:26 On error:
2021/02/23 15:51:26 Waiting on builds to complete...
2021/02/23 15:51:26 Starting build run: tencentcloud-cvm
2021/02/23 15:51:26 Running builder: tencentcloud-cvm
2021/02/23 15:51:26 [INFO] (telemetry) Starting builder tencentcloud-cvm
==> tencentcloud-cvm: Trying to check image name: our-image-name...
tencentcloud-cvm: Image name: useable
==> tencentcloud-cvm: Trying to check source image: ...
2021/02/23 15:51:28 [INFO] (telemetry) ending tencentcloud-cvm
==> tencentcloud-cvm: No image found under current instance_type(S2.MEDIUM4) restriction
==> Wait completed after 1 second 730 milliseconds
2021/02/23 15:51:28 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2021/02/23 15:51:28 machine readable: tencentcloud-cvm,error []string{"No image found under current instance_type(S2.MEDIUM4) restriction"}
==> Builds finished but no artifacts were created.
2021/02/23 15:51:28 [INFO] (telemetry) Finalizing.
Build 'tencentcloud-cvm' errored after 1 second 730 milliseconds: No image found under current instance_type(S2.MEDIUM4) restriction
==> Wait completed after 1 second 730 milliseconds
==> Some builds didn't complete successfully and had errors:
--> tencentcloud-cvm: No image found under current instance_type(S2.MEDIUM4) restriction
I tried to use Packer to create a Windows image on Tencent Cloud with the following code.
source "tencentcloud-cvm" "ws" {
secret_id = var.secret_id
secret_key = var.tc_secret_key
region = var.tc_region
zone = var.zone
disk_type = "CLOUD_PREMIUM"
communicator = "winrm"
winrm_username = "Administrator"
winrm_insecure = true
winrm_use_ssl = true
associate_public_ip_address = true
}
build {
name = "tc_base"
source "tencentcloud-cvm.ws" {
image_name = var.base_image_name
instance_type = var.tc_std_instance_type
source_image_id = var.source_image_id
}
provisioner "file" {
source = "powershell/profile.ps1"
destination = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\profile.ps1"
}
}
It failed with the error message below.
tc_base.tencentcloud-cvm.ws: output will be in this color.
==> tc_base.tencentcloud-cvm.ws: Trying to check image name: ws_image_base_test...
tc_base.tencentcloud-cvm.ws: Image name: useable
==> tc_base.tencentcloud-cvm.ws: Trying to check source image: img-bhvhr6pr...
tc_base.tencentcloud-cvm.ws: Image found: Windows Server 2019 DataCenter 64bit EN
==> tc_base.tencentcloud-cvm.ws: Trying to create a new keypair: packer_62434e6e...
tc_base.tencentcloud-cvm.ws: Keypair created: skey-rpzk9y6x
==> tc_base.tencentcloud-cvm.ws: Trying to create a new vpc...
tc_base.tencentcloud-cvm.ws: Vpc created: vpc-jsolyc1f
==> tc_base.tencentcloud-cvm.ws: Trying to create a new subnet...
tc_base.tencentcloud-cvm.ws: Subnet created: subnet-3x4e2awc
==> tc_base.tencentcloud-cvm.ws: Trying to create a new securitygroup...
tc_base.tencentcloud-cvm.ws: Securitygroup created: sg-4n5n7y8q
==> tc_base.tencentcloud-cvm.ws: Trying to create securitygroup polices...
tc_base.tencentcloud-cvm.ws: Securitygroup polices created
==> tc_base.tencentcloud-cvm.ws: Trying to create a new instance...
==> tc_base.tencentcloud-cvm.ws: Failed to run instance: [TencentCloudSDKError] Code=UnsupportedOperation.KeyPairUnsupportedWindows, Message=Key pair is unsupported for Windows instances, RequestId=38b4317b-982d-45a0-9092-c6da8bf9b0cb
==> tc_base.tencentcloud-cvm.ws: Deleting securitygroup because of error...
==> tc_base.tencentcloud-cvm.ws: Deleting subnet because of error...
==> tc_base.tencentcloud-cvm.ws: Deleting vpc because of error...
==> tc_base.tencentcloud-cvm.ws: Deleting keypair because of error...
Build 'tc_base.tencentcloud-cvm.ws' errored after 21 seconds 26 milliseconds: [TencentCloudSDKError] Code=UnsupportedOperation.KeyPairUnsupportedWindows, Message=Key pair is unsupported for Windows instances, RequestId=38b4317b-982d-45a0-9092-c6da8bf9b0cb
I'm wondering if Windows is supported. If true, would you please suggest how to fix this issue. Thanks!
Description
Plugin provides source_image option to find the base image in tencentcloud. For the time being, we should hard-code image names or their ids. It's a pain.
It would be nice to have ability to specify filters to find image by name regex or tags, like in AWS plugin:
https://github.com/hashicorp/packer-plugin-amazon/blob/main/docs/datasources/ami.mdx
image ID changes frequently, which makes the original template need to be modified frequently. This is very painful
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
Currently, the API call for create image will always have ForceStop set to true. This behavior will lead to some file modified during provisioning get lost in final image because modification has not been synced to disk in time.
Doing only echo 'root:testpwd' | chpasswd
and you should find password incorrect for root when start a new cvm.
Ubuntu, Github Action
ssia.
packer build -force .
Packer v1.8.0
packer {
required_plugins {
docker = {
version = "1.0.4"
source = "github.com/hashicorp/tencentcloud"
}
}
}
variable "secret_id" {
type = string
default = env("TENCENTCLOUD_SECRET_ID")
}
variable "secret_key" {
type = string
default = env("TENCENTCLOUD_SECRET_KEY")
}
source "tencentcloud-cvm" "cvm" {
associate_public_ip_address = true
disk_type = "CLOUD_PREMIUM"
image_name = "test"
instance_type = "S5.MEDIUM2"
packer_debug = true
region = "ap-tokyo"
secret_id = var.secret_id
secret_key = var.secret_key
source_image_id = "img-eb30mz89"
ssh_username = "root"
zone = "ap-tokyo-1"
}
build {
sources = ["source.tencentcloud-cvm.cvm"]
provisioner "shell" {
inline = ["echo \"Hello Word\""]
}
}
I found Tencent Cloud recently released a new region, Sao Paulo, and I tried to create an image in this region, but found it is not supported on Packer. Is it possible to add this new region to Packer?
This issue was originally opened by @virain as hashicorp/packer#10396. It was migrated here as a result of the Packer plugin split. The original body of the issue is below.
I used the packer to package the image. An ansible syntax error occurred. The packer stopped running and deleted the instance. After running the packer again, the prompt failed to wait for instance ready: instance (INS XXX) not exist
packer 1.6.5
==> tencentcloud-cvm.tencentcloud: Trying to use existing securitygroup: sg-ni4d1vkh...
tencentcloud-cvm.tencentcloud: Securitygroup found: default
2020/12/16 17:39:08 packer-builder-tencentcloud-cvm plugin: 2020/12/16 17:39:08 step_run_instance.go:198: [DEBUG]getUserData: user_data:
==> tencentcloud-cvm.tencentcloud: Trying to create a new instance...
tencentcloud-cvm.tencentcloud: Waiting for instance ready
==> tencentcloud-cvm.tencentcloud: Failed to wait for instance ready: instance(ins-jnoiqr60) not exist
==> tencentcloud-cvm.tencentcloud: Deleting instance because of error...
==> tencentcloud-cvm.tencentcloud: Failed to terminate instance(ins-jnoiqr60), please delete it manually: [TencentCloudSDKError] Code=InvalidInstanceId.NotFound, Message=The specified instance ID `['ins-jnoiqr60']` is not found., RequestId=ccb15216-aac2-4344-ae56-d8579418acfe
==> tencentcloud-cvm.tencentcloud: Deleting keypair because of error...
2020/12/16 17:39:09 [INFO] (telemetry) ending
==> Wait completed after 3 seconds 64 milliseconds
Build 'tencentcloud-cvm.tencentcloud' errored after 3 seconds 64 milliseconds: instance(ins-jnoiqr60) not exist
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.