Alicloud (Alibaba Cloud) packer provider
This is the official repository for the Alicloud packer provider.
Currently it supports packer version ≥ v0.12.1.
If you are not planning to contribute to this repo, you can download the compiled binaries according to you platform, unzip and move them into the folder under the packer PATH such as /usr/local/packer.
- Download the correct packer from you platform from https://www.packer.io/downloads.html
- Install packer according to the guide from https://www.packer.io/docs/installation.html
- Install Go according to the guide from https://golang.org/doc/install
- Setup your access key and secret key in the environment variables according to platform, for example In Linux platform with default bash, open your .bashrc in your home directory and add following two lines
export ALICLOUD_ACCESS_KEY="access key value" export ALICLOUD_SECRET_KEY="secret key value"
- Open a terminator and clone Alicloud packer provider and build,install and test
cd <$GOPATH> mkdir -p src/github.com/alibaba/ cd <$GOPATH>/src/github.com/alibaba/ git clone https://github.com/alibaba/packer-provider cd <$GOPTH>/src/github.com/alibaba/packer-provider make all sorce ~/.bashrc packer build example/alicloud.jsonIf output similar as following, configurations, you can now start the journey of alicloud with packer support
alicloud output will be in this color. ==> alicloud: Force delete flag found, skipping prevalidating Alicloud ECS Image Name alicloud: Found Image ID: centos_7_03_64_20G_alibase_20170818.vhd ==> alicloud: allocated eip address 121.196.193.14 ==> alicloud: Instance starting ==> alicloud: Waiting for SSH to become available... ==> alicloud: This machine's host=121.196.193.14 ==> alicloud: This machine's host=121.196.193.14 ==> alicloud: This machine's host=121.196.193.14 ==> alicloud: Connected to SSH! ==> alicloud: Provisioning with shell script: /var/folders/3q/w38xx_js6cl6k5mwkrqsnw7w0000gn/T/packer-shell170579778{ "variables": { "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}", "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}" }, "builders": [{ "type":"alicloud-ecs", "access_key":"{{user `access_key`}}", "secret_key":"{{user `secret_key`}}", "region":"cn-beijing", "image_name":"packer_test2", "source_image":"centos_7_03_64_20G_alibase_20170818.vhd", "ssh_username":"root", "instance_type":"ecs.n1.tiny", "io_optimized":"true", "internet_charge_type":"PayByTraffic", "image_force_delete":"true" }], "provisioners": [{ "type": "shell", "inline": [ "sleep 30", "yum install redis.x86_64 -y" ] }] }{ "variables": { "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}", "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}" }, "builders": [{ "type":"alicloud-ecs", "access_key":"{{user `access_key`}}", "secret_key":"{{user `secret_key`}}", "region":"cn-beijing", "image_name":"packer_test", "source_image":"win2008r2_64_ent_sp1_zh-cn_40G_alibase_20170915.vhd", "instance_type":"ecs.n1.tiny", "internet_charge_type":"PayByTraffic", "io_optimized":"true", "image_force_delete":"true", "communicator": "winrm", "winrm_port": 5985, "winrm_username": "Administrator", "winrm_password": "Test1234", "user_data_file": "examples/alicloud/basic/winrm_enable_userdata.ps1" }], "provisioners": [{ "type": "powershell", "inline": ["dir c:\\"] }] }
Note: Since WinRM is closed by default in the system image. You need enable it by userdata in order to connect to the instance, check winrm_enable_userdata.ps1 for details.
{ "variables": { "access_key": "{{env `ALICLOUD_ACCESS_KEY`}}", "secret_key": "{{env `ALICLOUD_SECRET_KEY`}}" }, "builders": [{ "type":"alicloud-ecs", "access_key":"{{user `access_key`}}", "secret_key":"{{user `secret_key`}}", "region":"cn-beijing", "image_name":"packer_with_data_disk", "source_image":"centos_7_03_64_20G_alibase_20170818.vhd", "ssh_username":"root", "instance_type":"ecs.n1.tiny", "internet_charge_type":"PayByTraffic", "io_optimized":"true", "image_disk_mappings":[{"disk_name":"data1","disk_size":20},{"disk_name":"data1","disk_size":20,"disk_device":"/dev/xvdz"}] }], "provisioners": [{ "type": "shell", "inline": [ "sleep 30", "yum install redis.x86_64 -y" ] }] }Note: Images can become deprecated after a while; run
aliyun ecs DescribeImagesto find one that exists.Here are more examples include chef, jenkins image template etc.
- If you are not sure or have any doubts, feel free to ask and/or submit an issue or PR. We appreciate all contributions and don't want to create artificial obstacles that get in the way.
- Contributions are welcome and will be merged via PRs.
- zhuzhih2017
- This project is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.
- Pakcer document: https://www.packer.io/intro/
packer-provider's People
Forkers
golang-jheengut xiaozhu36 go-learn zhuzhih2017 cosmos-sun luminousssss magic-chenyang seanly ellerbrock cloud-architecture archerslaw khanchan zhanwenzhuo-github chhaj5236 alex1528 ocean-token lrxcy shawnmssu alexyueer xeooon click2cloud icedroid gaojianlipplabs bertonlan jaty613 ren-maomaopacker-provider's Issues
use packer version 1.9.4 , packer build alicloud.json is error . When can Aliyun support Packer 1.9.4
use packer version 1.9.4 , packer build alicloud.json is error . When can Aliyun support Packer 1.9.4
Add 'Hostname' ECS parameter to create.
If someone wouldn't mind adding the 'Hostname' config option when creating an ECS instance it would be very helpful. This could even simplify the chef example. I am trying to build an application which expects the hostname to be set to something reasonable and the default Alibaba hostname is a simple uuid.
https://www.alibabacloud.com/help/doc-detail/25499.htm
https://github.com/alibaba/packer-provider/blob/master/ecs/run_config.goUnable to delete resources after creating snapshot or image
After creating the image it show an error in deleting security group.
alicloud-ecs: Error delete security group failed, may still be around: Aliyun API Error: RequestId: B9212A42-1E07-45A8-9AE0-D940217B0234 Status Code: 403 Code: DependencyViolation Message: There is still instance(s) in the specified security group.
The ECS instance created by packer is still in stopped state and I need to release it manually and I also need to delete the VPC, VSWitch manually.
eip brandwith setting does not work
"internet_charge_type": "PayByTraffic", "internet_max_bandwidth_out": 100,set the two fields above in packer config JSON file, and run packer build, the brand width of the EIP allocated by packer was set to 5Mbps。
reason: packer does not pass BrandWidth param when allocate EIP and the EIP use the default brand width which is 5Mbps.
if b.chooseNetworkType() == VpcNet { steps = append(steps, &setpConfigAlicloudEIP{ AssociatePublicIpAddress: b.config.AssociatePublicIpAddress, RegionId: b.config.AlicloudRegion, InternetChargeType: b.config.InternetChargeType, }) } else { steps = append(steps, &stepConfigAlicloudPublicIP{ RegionId: b.config.AlicloudRegion, }) }This should be a bug and need to be fixed.
When specifying a security group in Packer, if there are more than 10 security groups in the region and the specified security group comes after the 10th in DescribeSecurityGroups, Packer says the SG does not exist
unable to delete existing image although image_force_delete is set to true
I want to overwrite the image that being buit, I already define the
image_force_deleteto true yet aliyun still told me this errorBuild 'alicloud-ecs' errored: Failed to delete image: Aliyun API Error: RequestId: 9E670E6C-06B9-4253-BBDC-771E6CB5CE1D Status Code: 403 Code: ImageUsingByInstance Message: The specified image has been used to create instances.Error allocation EIP
hi
I'm mosuke5.
I tried to use packer-provider. but following error happened.
When allocationg eip to ecs instance, error happened.
Do you know this reason?Alicloud-ecs output will be in this color. ==> alicloud-ecs: Force delete flag found, skipping prevalidating image name. alicloud-ecs: Found image ID: centos_7_2_64_40G_base_20170222.vhd ==> alicloud-ecs: Creating temporary keypair: packer_5981613f-b3e4-c283-d3d8-73906ca10090 ==> alicloud-ecs: Creating vpc ==> alicloud-ecs: Creating vswitch... ==> alicloud-ecs: Creating security groups... ==> alicloud-ecs: Creating instance. ==> alicloud-ecs: Allocating eip ==> alicloud-ecs: Error allocating eip: Aliyun API Error: RequestId: E2DA928E-9E73-4790-962B-BC6B41BC475E Status Code: 400 Code: UnknownError Message: The request processing has failed due to some unknown error. ==> alicloud-ecs: Deleting instance because of cancellation or error...I used this template json.
{ "variables": { "access_key": "xxxxxxxxxxxx", "secret_key": "xxxxxxxxxxxxx" }, "builders": [{ "type":"alicloud-ecs", "access_key":"{{user `access_key`}}", "secret_key":"{{user `secret_key`}}", "region":"ap-southeast-1", "image_name":"packer_test2", "source_image":"centos_7_2_64_40G_base_20170222.vhd", "ssh_username":"root", "instance_type":"ecs.n1.tiny", "io_optimized":"true", "image_force_delete":"true" }], "provisioners": [{ "type": "shell", "inline": [ "sleep 30", "yum install redis.x86_64 -y" ] }] }Error deleting vpc
The images created successfully but error deleting VPC.
==> alicloud-ecs: Deleting image snapshots. ==> alicloud-ecs: Creating image: packer-juicefs-node-1522915639 alicloud-ecs: Detach keypair packer_5ac5d937-5b1c-c17c-23f7-9b739f6f57f7 from instance: i-2ze7zj85weet69vckag2 ==> alicloud-ecs: Cleaning up 'EIP' ==> alicloud-ecs: Cleaning up 'instance' ==> alicloud-ecs: Cleaning up 'security group' ==> alicloud-ecs: Cleaning up 'vSwitch' ==> alicloud-ecs: Cleaning up 'VPC' ==> alicloud-ecs: Error deleting vpc, it may still be around: Aliyun API Error: RequestId: 2267AF22-9D65-4730-AB6B-8C41E1420DAC Status Code: 400 Code: Forbbiden Message: Active custom route in vpc. ==> alicloud-ecs: Deleting temporary keypair... Build 'alicloud-ecs' finished.The vpc can be deleted from console successfully although it includes a route table.
Adding a Password parameter for troubleshooting
Any chance we can get a password parameter for troubleshooting instances that fail to create? There is a disable_stop_instance flag for this purpose, I would like some way to easily login to the server. I can't find a way to get the temp key or set a password on image creation fail.
alicloud-ecs: Waiting for SSH to become available...
==> alicloud-ecs: Waiting for SSH to become available...
==> alicloud-ecs: Error waiting for SSH: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain按照https://help.aliyun.com/document_detail/60822.html 这篇官方文档执行总是卡在ssh上,请问哪里配置有问题呢?
No alicloud image was found matching filters: centos_7_9_x64_20G_alibase_20211027.vhd
Hi,
We are trying to build a image base on official image, and using the official published image from page https://help.aliyun.com/document_detail/100410.html
But we got the error "no matching image found". Please help on this. thanks!
+ packer build base.json �[1;32malicloud-ecs: output will be in this color.�[0m �[1;32m==> alicloud-ecs: Prevalidating source region and copied regions...�[0m �[1;32m==> alicloud-ecs: Prevalidating image name...�[0m �[1;31m==> alicloud-ecs: No alicloud image was found matching filters: centos_7_9_x64_20G_alibase_20211027.vhd�[0m �[1;31mBuild 'alicloud-ecs' errored after 855 milliseconds 521 microseconds: No alicloud image was found matching filters: centos_7_9_x64_20G_alibase_20211027.vhd�[0m ==> Wait completed after 855 milliseconds 711 microseconds ==> Some builds didn't complete successfully and had errors: --> alicloud-ecs: No alicloud image was found matching filters: centos_7_9_x64_20G_alibase_20211027.vhdlatest source_image
is it possible to get an image automatically?
"source_image": "ubuntu_16_04_64_20G_alibase_20190301.vhd"
maybe use?
"source_image": "ubuntu_16_04_64_20G_alibase_*.vhd"
or how used in GCE
"source_image_family": "ubuntu-1604-lts"
TY!
Can't create image for instance type ecs.gn5-c4g1.xlarge
Hi I'm trying to create an instance for the type ecs.gn5-c4g1.xlarge.
I get the error "InvalidDiskCategory.CreateImage".I think it's because packer tries to create an image of the I/O-Intensive Local Disk 440GB.
I don't need to create an image of this, just of system disk.By default, this instance type creates two disks:

Can I instruct packer to create an image only for the system disk, and not the second disk ?
Thanks !source_image cannot use customer image name? only image id ?
centos_7_06_64_20G_system_init_2019072301 is my private image name,
packer error log:
==> alicloud-ecs: No alicloud image was found matching filters: centos_7_06_64_20G_system_init_2019072301
Build 'alicloud-ecs' errored: No alicloud image was found matching filters: centos_7_06_64_20G_system_init_2019072301unknown configuration key: '"custom_endpoint_ecs"'
I tried assign custom_endpoint_ecs to build ecs images for privacy scenrio but follow error occurred:
Error: Failed to prepare build: "alicloud-ecs"
1 error occurred:
* unknown configuration key: '"custom_endpoint_ecs"'The documentation here explains the support for the option custom_endpoint_ecs, https://www.packer.io/docs/builders/alicloud#custom_endpoint_ecs
WINRM Password not recognised if they contain "_" - This is a valid windows password character
I noticed this on the gui for ec2 launch but thought it just affected that but if you have
SNIPED For brevity
"variables": {
"username" : "myadmin",
"password" : "Password1With_In1t"
},
"builders" :[
{ "name": "alicloud.eu-central-1.ecs.gn5-c4g1.xlarge",
"communicator": "winrm",
"winrm_username": "{{userusername}}",
"winrm_password": "{{userpassword}}"}]on packer build you get
Build 'alicloud.eu-central-1.ecs.gn5-c4g1.xlarge' errored: Error creating instance: Aliyun API Error: RequestId: 1020D6CC-20A8-4CF9-8F7B-54EB88B239BD Status Code: 400 Code: InvalidPassword.Malformed Message: The specified parameter "Password" is not valid.
=> Some builds didn't complete successfully and had errors:If you remove the _ from the password then they start to build.
The "_" is a valid character for windows passwords and should be allowedHow to specify a classic network type to build image?
Try to do this
{ "type":"alicloud-ecs", "access_key":"{{user `alicloud_access_key`}}", "secret_key":"{{user `alicloud_secret_key`}}", "region":"cn-shanghai", "image_name":"CodingCE-1.0", "source_image":"ubuntu_16_0402_64_40G_base_20170222.vhd", "ssh_username":"root", "instance_type":"ecs.n2.medium", "io_optimized":"true", "image_force_delete":"true", "networktype":"classic" }but get errors:
Error attaching keypair
alicloud-ecs: Error attaching keypair packer_5965d231-20d8-2d88-04d7-05559a18878d to instance i-2zei5wmjez4q2za8pl49 : Aliyun API Error: RequestId: 699E67CC-EEB8-4DF7-B019-F921F8AA1464 Status Code: 503 Code: ServiceUnavailable Message: The request has failed due to a temporary failure of the server.
I am using 'centos_7_03_64_40G_alibase_20170625.vhd' as the source image of Packer
build error
panic: gob: registering duplicate names for *map[string]interface {}: "map[string]interface {}" != "*map[string]interface {}"
goroutine 1 [running]:
encoding/gob.RegisterName(0x204e6f6, 0x18, 0x2151ec0, 0xc42020a920)
/usr/local/golang/src/encoding/gob/type.go:826 +0x4cc
encoding/gob.Register(0x2151ec0, 0xc42020a920)
/usr/local/golang/src/encoding/gob/type.go:874 +0x127
github.com/hashicorp/packer/packer/rpc.init.0()
/home/src/github.com/hashicorp/packer/packer/rpc/init.go:6 +0x41
github.com/hashicorp/packer/packer/rpc.init()
:1 +0x89
github.com/hashicorp/packer/packer/plugin.init()
:1 +0x5f
api/packer.init()
:1 +0x67
api.init()
:1 +0x5d
main.init()
:1 +0x4e"image_ignore_data_disks":"true" gives error on launch
after updating to new release
When setting "image_ignore_data_disks":"true",I now immediately get
uild 'TEST.alicloud.eu-central-1.ecs.gn5-c4g1.xlarge' errored: Aliyun API Error: RequestId: Status Code: 400 Code: InvalidEndpoint Message: endpoint is empty,pls check
uild 'alicloud.eu-central-1.ecs.gn5-c4g1.xlarge' errored: Aliyun API Error: RequestId: Status Code: 400 Code: InvalidEndpoint Message: endpoint is empty,pls checkIf I remove it, its launches and builds as normal but the gives the original error at the end when it tries to create the image
Setting windows password on new bare OS installs
I want to use packer to create our own bare windows OS images that are windows_updated and have other (specific to us) core software installed.
If I'm reading the docs correctly I need to set the password field to a value and then use that password in my winrm communicator.
When I try and launch using the below script as an example I get the following error- unknown configuration key: "password"
Am I doing something wrong? Or is there a way that the ecs instance autogenerates its administrator password and that winrm can somehow pick it up?
"variables": {
"build_version": "{{envWIN_BUILD}}",
"image_name": "BaseWindowsServer2012-V{{envWIN_BUILD}}",
"packer_timestamp" :"{{timestamp}}",
"winrm_username": "{{envWINRM_user}}",
"winrm_password": "{{envWINRM_password}}",
"ALI_access_key": "{{envALICLOUD_ACCESS_KEY}}",
"ALI_secret_key": "{{envALICLOUD_SECRET_KEY}}",
"source_image": "win2012r2_64_dtc_17196_en-us_40G_alibase_20170915.vhd"
},
"builders" :[
{ "name": "alicloud.eu-central-1.ecs.gn5-c4g1.xlarge",
"type":"alicloud-ecs",
"access_key":"{{userALI_access_key}}",
"secret_key":"{{userALI_secret_key}}",
"region":"eu-central-1",
"vpc_id":"xxxxxx",
"vswitch_id":"xxxxx",
"security_group_id":"xxxxxx",
"instance_type":"ecs.gn5-c4g1.xlarge",
"instance_name": "PACKER_{{userimage_name}}v{{userbuild_version}}{{build_name}}{{userpacker_timestamp}}",
"internet_charge_type":"PayByTraffic",
"internet_max_bandwidth_out": "100",
"source_image":"{{usersource_image}}",
"password":"{{userwinrm_password}}",
"image_name":"packer{{userimage_name}}_{{userregion}}",
"image_description":"Built for use on YellowDog systems",
"image_version":"v{{userbuild_version}}",
"image_ignore_data_disks":"true",
"io_optimized":"true",
"image_force_delete":"true",
"communicator": "winrm",
"winrm_username": "{{userwinrm_username}}",
"winrm_password": "{{userwinrm_password}}",
"winrm_timeout": "24h",
"winrm_use_ssl": false,
"winrm_insecure": true
}
],How to get rid of this forbidden message?
Hi
I am using my super keys to create ecs image and was kicked out by "RiskControl system".
--> alicloud-ecs: Error creating instance: Aliyun API Error: RequestId: AFB6A213-884C-4571-A544-70F4126384E0 Status Code: 403 Code: Forbidden.RiskControl Message: This operation is forbidden by Aliyun RiskControl system.How am I going to proceed next?
thanks
Unable to set the System Disk size
From my reading of the docs I need to set image_disk_mappings -> disk_size if i want a custom system disk size
"disk_size (number) - Size of the system disk, in GB, values range:"I'm setting it in packer as follows:
"image_disk_mappings":[{"disk_size":256}],
but this always creates a secondary data disk of 256GB leaving the system disk at 40GB, custom disk sizes work ok from the console. Is this something I am doing wrong? How can you set a custom system disk size in packer?net/http: TLS handshake timeout
hello Dev,
I faced frequent issue when I use ali-packer. I don't know why?
alicloud-ecs: Timeout waiting for instance to start: Aliyun API Error: RequestId: Status Code: -1 Code: AliyunGoClientFailure Message: Get https://ecs-cn-hangzhou.aliyuncs.com?xx: net/http: TLS handshake timeout
following is the code:
{
"variables": {
"access_key": "{{envALICLOUD_ACCESS_KEY}}",
"secret_key": "{{envALICLOUD_SECRET_KEY}}"
},
"builders": [{
"type":"alicloud-ecs",
"access_key":"{{useraccess_key}}",
"secret_key":"{{usersecret_key}}",
"region":"cn-beijing",
"image_name":"packer_test2",
"source_image":"centos_7_03_64_20G_alibase_20170818.vhd",
"ssh_username":"root",
"instance_type":"ecs.n1.tiny",
"io_optimized":"true",
"internet_charge_type":"PayByTraffic",
"image_force_delete":"true"
}],
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
"yum install redis.x86_64 -y"
]
}]
}Facing issue while running code.
which RAM access is required?
Hi
I am using RAM to build ecs image. As you can see, it was forbidden. Could you please point me out which access I should have granted my robot account?
Build 'alicloud-ecs' errored: Aliyun API Error: RequestId: 3AB7DE95-65DB-4F36-85F1-109820DDD8D0 Status Code: 403 Code: Forbidden.RAM Message: User not authorized to operate on the specified resource, or this API doesn't support RAM.thanks.
support resource_group_id
Like terraform has “resource_group_id ” field
Because i just have permission in special resource_group
Can packer provide this field ?
About supporting JP region
Hi.
Does this software support JP region(ap-northeast-1)?
When I tried build to JP region, following error happened.
I guess not supporting JP region.$ packer build test.json alicloud-ecs output will be in this color. ==> alicloud-ecs: Force delete flag found, skipping prevalidating image name. ==> alicloud-ecs: Error querying alicloud image: Aliyun API Error: RequestId: Status Code: -1 Code: AliyunGoClientFailure Message: unexpected end of JSON input Build 'alicloud-ecs' errored: Error querying alicloud image: Aliyun API Error: RequestId: Status Code: -1 Code: AliyunGoClientFailure Message: unexpected end of JSON input ==> Some builds didn't complete successfully and had errors: --> alicloud-ecs: Error querying alicloud image: Aliyun API Error: RequestId: Status Code: -1 Code: AliyunGoClientFailure Message: unexpected end of JSON input ==> Builds finished but no artifacts were created.No alicloud image was found matching filters: ubuntu_20_04_x64_20G_alibase_20220824.vhd
Hi,
For some reason trying to start Ubuntu 20 fails with a 'no image found' message, although the image is listed here:
Config is the following:
"type": "alicloud-ecs", "access_key": "edited-out", "secret_key": "edited-out", "region": "eu-central-1", "instance_type": "ecs.n1.tiny", "image_name": "edited-out", "source_image": "ubuntu_20_04_x64_20G_alibase_20220824.vhd", "ssh_username": "ecs-user"Why is there a mismatch?
D
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
OpenClaw
Personal AI Assistant
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
- Open a terminator and clone Alicloud packer provider and build,install and test

