Code Monkey home page Code Monkey logo

packer-plugin-tencentcloud's Introduction

Packer Plugin Tencentcloud

The Tencentcloud multi-component plugin can be used with HashiCorp Packer to create custom images. For the full list of available features for this plugin see docs.

Installation

Using pre-built releases

Using the packer init command

Starting from version 1.7, Packer supports a new packer init command allowing automatic installation of Packer plugins. Read the Packer documentation for more information.

To install this plugin, copy and paste this code into your Packer configuration . Then, run packer init.

packer {
  required_plugins {
    tencentcloud = {
      version = ">= 1.2.0"
      source  = "github.com/hashicorp/tencentcloud"
    }
  }
}

Manual installation

You can find pre-built binary releases of the plugin here. Once you have downloaded the latest archive corresponding to your target OS, uncompress it to retrieve the plugin binary file corresponding to your platform. To install the plugin, please follow the Packer documentation on installing a plugin.

From Sources

If you prefer to build the plugin from sources, clone the GitHub repository locally and run the command go build from the root directory. Upon successful compilation, a packer-plugin-tencentcloud plugin binary file can be found in the root directory. To install the compiled plugin, please follow the official Packer documentation on installing a plugin.

Configuration

For more information on how to configure the plugin, please read the documentation located in the docs/ directory.

Contributing

  • If you think you've found a bug in the code or you have a question regarding the usage of this software, please reach out to us by opening an issue in this GitHub repository.
  • Contributions to this project are welcome: if you want to add a feature or a fix a bug, please do so by opening a Pull Request in this GitHub repository. In case of feature contribution, we kindly ask you to open an issue to discuss it beforehand.

packer-plugin-tencentcloud's People

Contributors

azr avatar dependabot[bot] avatar gitmkn avatar hashicorp-copywrite[bot] avatar hellertang avatar jescalan avatar jinxingyoung avatar ksatirli avatar lbajolet-hashicorp avatar likexian avatar modrake avatar naoyukis avatar nywilken avatar piggona avatar rogerhu avatar shengyu avatar shinny-taojiachun avatar swampdragons avatar sylviamoss avatar takaishi avatar williamb1024 avatar ysicing avatar zchsh avatar zqfan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-tencentcloud's Issues

The force option is no longer working

Overview of the Issue

ssia.

Reproduction Steps

packer build -force .

Plugin and Packer version

Packer v1.8.0

Simplified Packer Buildfile

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\""]
  }
}

Find source image by filters

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

ForceStop option is ignored and is always true

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

Overview of the Issue

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.

Reproduction Steps

Doing only echo 'root:testpwd' | chpasswd and you should find password incorrect for root when start a new cvm.

Plugin and Packer version

Simplified Packer Buildfile

Operating system and Environment details

Ubuntu, Github Action

Log Fragments and crash.log files

Sao Paulo region is not supported

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?

[TencentCloud] `source_image_name` failed to retrieve source image by name

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.


Overview of the Issue

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

Reproduction Steps

Steps to reproduce this issue

packer build

Packer version

1.7.0

Simplified Packer Buildfile

"source_image_name": "our-source-image-name",

Log Fragments and crash.log files

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

Does this plugin support Windows?

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!

TencentCloudSDKError Code=InvalidPermission, Message=Bandwidth package user does not support the value `TRAFFIC_POSTPAID_BY_HOUR` in the parameter `.InternetAccessible.InternetChargeType`

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

tencentcloud-cvm Failed to wait for instance ready: instance(ins-xxxx) not exist

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.


Overview of the Issue

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

error logs

==> 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.