hashicorp / packer-plugin-alicloud Goto Github PK
View Code? Open in Web Editor NEWPacker plugin for Alibaba Cloud Image Builder
Home Page: https://www.packer.io/docs/builders/alicloud-ecs
License: Mozilla Public License 2.0
Packer plugin for Alibaba Cloud Image Builder
Home Page: https://www.packer.io/docs/builders/alicloud-ecs
License: Mozilla Public License 2.0
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Currently, only one security group ID can be supplied to an instance with security_group_id
. It would be great to be able to supply a list of security group IDs via a new parameter: security_group_ids
.
Attach multiple, pre-existing security groups to an instance created by packer instead of just one.
{
"security_group_ids": [
"sg-...",
"sg-...",
"sg-..."
]
}
SecurityGroupIds
in link), the list needs to be formatted into a string representation of a JSON array with a max of 100 secgroups: https://www.alibabacloud.com/help/en/elastic-compute-service/latest/describesecuritygroupswhen run packer build in an ECS server in which RamRoleArn mode is configured, if the profile attributes are configured, the packer build doesn't work.
aliyun
cli tool with RamRoleArn modesource "alicloud-ecs" "base" {
image_name = "${var.image_name}-${local.timestamp}"
image_share_account = var.image_share_account
internet_charge_type = var.internet_charge_type
instance_type = var.instance_type
io_optimized = var.io_optimized
profile = "ram_user"
shared_credentials_file = "$HOME/.aliyun/config.json"
region = "cn-shenzhen"
source_image = "ubuntu_20_04_x64_20G_alibase_20220824"
system_disk_mapping {
disk_size = var.disk_size
disk_category = var.disk_category
}
}
ubuntu 18.04
alicloud-ecs: output will be in this color.
==> alicloud-ecs: Prevalidating source region and copied regions...
==> alicloud-ecs: Force delete flag found, skipping prevalidating image name.
==> alicloud-ecs: No alicloud image was found matching filters: ubuntu_20_04_x64_20G_alibase_20220824.vhd
Build 'alicloud-ecs' errored after 1 second 708 milliseconds: No alicloud image was found matching filters: ubuntu_20_04_x64_20G_alibase_20220824.vhd
==> Wait completed after 1 second 708 milliseconds
==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: No alicloud image was found matching filters: ubuntu_20_04_x64_20G_alibase_20220824.vhd
==> Builds finished but no artifacts were created.
This issue was originally opened by @syy6 in hashicorp/packer#7662 and has been migrated to this repository. The original issue description is below.
Hi All,
Just using Packer 1.4.1 in AliCloud to pack below test.json, but got error like below. We have checked with AliCloud support team, it seems that the reason is Packer takes the empty string in Tag segment in JSON as Null and passes the Null value to AliCloud SDK, then the issue will happen. Coudl U please help to check for this issue? Thanks!
BR,
Yongyuan
Error:
==> alicloud-ecs: Stopping instance: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Waiting instance stopped: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Creating image: packer_basic
==> alicloud-ecs: Adding tags(map[Application: Base BuildID:2019.05.17 Date:2019-05-17T14:54:02+0000 Environment: GIT Commit: Name: Base OS_Version:SLES12.3 Region:cn-shanghai Stream:default Validation:NotRun]) to image: m-uf66na2l6bjsufaa75yz
==> alicloud-ecs: Error Adding tags to image: SDK.ServerError
==> alicloud-ecs: ErrorCode: InvalidTagValue.Malformed
==> alicloud-ecs: Recommend:
==> alicloud-ecs: RequestId: 376249D2-8423-4F2F-9598-09650770758F
==> alicloud-ecs: Message: The specified Tag.n.Value is not valid.
==> alicloud-ecs: Deleting the image and related snapshots because of cancellation or error...
alicloud-ecs: Detach keypair packer_5ce21f2b-8c04-c23a-6879-968729e560ba from instance: i-uf68j36u3rzixynwnb8q
==> alicloud-ecs: Deleting EIP because of cancellation or error...
==> alicloud-ecs: Deleting instance because of cancellation or error...
==> alicloud-ecs: Deleting security group because of cancellation or error...
==> alicloud-ecs: Deleting vSwitch because of cancellation or error...
==> alicloud-ecs: Deleting VPC because of cancellation or error...
==> alicloud-ecs: Deleting temporary keypair...
Build 'alicloud-ecs' errored: Error Adding tags to image: SDK.ServerError
ErrorCode: InvalidTagValue.Malformed
Recommend:
RequestId: 376249D2-8423-4F2F-9598-09650770758F
Message: The specified Tag.n.Value is not valid.
==> Some builds didn't complete successfully and had errors:
--> alicloud-ecs: Error Adding tags to image: SDK.ServerError
ErrorCode: InvalidTagValue.Malformed
Recommend:
RequestId: 376249D2-8423-4F2F-9598-09650770758F
Message: The specified Tag.n.Value is not valid.
==> Builds finished but no artifacts were created.
test.json
{
"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-shanghai",
"image_name": "packer_basic",
"source_image": "centos_7_02_64_20G_alibase_20170818.vhd",
"ssh_username": "root",
"instance_type": "ecs.t5-lc2m1.nano",
"internet_charge_type": "PayByTraffic",
"io_optimized": "true",
"tags": {
"Name": "Base",
"OS_Version": "CentOS",
"Date": "2019-05-17T14:54:02+0000",
"BuildID": "2019.05.17",
"Application": "Base",
"Region": "cn-shanghai",
"Environment": "",
"GIT Commit": "",
"Stream": "default",
"Validation": "NotRun"
}
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sleep 30",
"yum install redis.x86_64 -y"
]
}
]
}
This issue was originally opened by @Forrest2023github in hashicorp/packer#12896 and has been migrated to this repository. The original issue description is below.
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
1, very similar to hashicorp/packer#11656, but on alicloud
2, tried with "temporary_key_pair_type": "ed25519" as well
it seems the packer-plugin-alicloud does support "temporary_key_pair_type" - https://developer.hashicorp.com/packer/integrations/hashicorp/alicloud/latest/components/builder/alicloud-ecs
1.10.2
1.1.1
"builders":[
{
"name": "alicloud-ecs-centos-stream9",
"type": "alicloud-ecs",
"temporary_key_pair_type": "ed25519",
"access_key": "xxxxxxxxxxxxxxxx",
"secret_key": "xxxxxxxxxxxx",
"source_image": "xxxxxxxxxxxxxx",
"instance_type": "ecs.sn1.medium",
"region": "us-east-1",
"image_name": "xxxxxxxxxxxxxxx",
"image_force_delete": "true",
"instance_name": "xxxxxxxxxxx",
"internet_charge_type": "PayByTraffic",
"io_optimized": "true",
"ssh_username": "root"
}
]
............
00:25:43 ==> alicloud-ecs.alicloud-ecs-centos-stream9: Using SSH communicator to connect:
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [INFO] Waiting for SSH, up to timeout: 5m0s
00:25:43 ==> alicloud-ecs.alicloud-ecs-centos-stream9: Waiting for SSH to become available...
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [INFO] Attempting SSH connection to :22...
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [DEBUG] reconnecting to TCP connection for SSH
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [DEBUG] handshaking with SSH
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:25:43 2024/03/21 00:25:43 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:43 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:25:50 2024/03/21 00:25:50 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:50 [INFO] Attempting SSH connection to :22...
00:25:50 2024/03/21 00:25:50 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:50 [DEBUG] reconnecting to TCP connection for SSH
00:25:50 2024/03/21 00:25:50 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:50 [DEBUG] handshaking with SSH
00:25:50 2024/03/21 00:25:50 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:50 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:25:50 2024/03/21 00:25:50 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:50 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:25:57 2024/03/21 00:25:57 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:57 [INFO] Attempting SSH connection to :22...
00:25:57 2024/03/21 00:25:57 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:57 [DEBUG] reconnecting to TCP connection for SSH
00:25:57 2024/03/21 00:25:57 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:57 [DEBUG] handshaking with SSH
00:25:57 2024/03/21 00:25:57 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:57 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:25:57 2024/03/21 00:25:57 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:25:57 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:04 2024/03/21 00:26:04 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:04 [INFO] Attempting SSH connection to :22...
00:26:04 2024/03/21 00:26:04 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:04 [DEBUG] reconnecting to TCP connection for SSH
00:26:04 2024/03/21 00:26:04 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:04 [DEBUG] handshaking with SSH
00:26:04 2024/03/21 00:26:04 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:04 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:04 2024/03/21 00:26:04 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:04 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:11 2024/03/21 00:26:11 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:11 [INFO] Attempting SSH connection to :22...
00:26:11 2024/03/21 00:26:11 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:11 [DEBUG] reconnecting to TCP connection for SSH
00:26:11 2024/03/21 00:26:11 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:11 [DEBUG] handshaking with SSH
00:26:11 2024/03/21 00:26:11 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:11 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:11 2024/03/21 00:26:11 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:11 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:18 2024/03/21 00:26:18 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:18 [INFO] Attempting SSH connection to :22...
00:26:18 2024/03/21 00:26:18 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:18 [DEBUG] reconnecting to TCP connection for SSH
00:26:18 2024/03/21 00:26:18 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:18 [DEBUG] handshaking with SSH
00:26:18 2024/03/21 00:26:18 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:18 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:18 2024/03/21 00:26:18 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:18 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:25 2024/03/21 00:26:25 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:25 [INFO] Attempting SSH connection to :22...
00:26:25 2024/03/21 00:26:25 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:25 [DEBUG] reconnecting to TCP connection for SSH
00:26:25 2024/03/21 00:26:25 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:25 [DEBUG] handshaking with SSH
00:26:25 2024/03/21 00:26:25 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:25 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:25 2024/03/21 00:26:25 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:25 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:32 2024/03/21 00:26:32 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:32 [INFO] Attempting SSH connection to :22...
00:26:32 2024/03/21 00:26:32 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:32 [DEBUG] reconnecting to TCP connection for SSH
00:26:32 2024/03/21 00:26:32 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:32 [DEBUG] handshaking with SSH
00:26:32 2024/03/21 00:26:32 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:32 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:32 2024/03/21 00:26:32 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:32 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:39 2024/03/21 00:26:39 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:39 [INFO] Attempting SSH connection to :22...
00:26:39 2024/03/21 00:26:39 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:39 [DEBUG] reconnecting to TCP connection for SSH
00:26:39 2024/03/21 00:26:39 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:39 [DEBUG] handshaking with SSH
00:26:39 2024/03/21 00:26:39 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:39 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:39 2024/03/21 00:26:39 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:39 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:46 2024/03/21 00:26:46 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:46 [INFO] Attempting SSH connection to :22...
00:26:46 2024/03/21 00:26:46 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:46 [DEBUG] reconnecting to TCP connection for SSH
00:26:46 2024/03/21 00:26:46 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:46 [DEBUG] handshaking with SSH
00:26:46 2024/03/21 00:26:46 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:46 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
00:26:46 2024/03/21 00:26:46 packer-plugin-alicloud_v1.1.1_x5.0_linux_amd64 plugin: 2024/03/21 00:26:46 [DEBUG] Detected authentication error. Increasing handshake attempts.
00:26:46 ==> alicloud-ecs.alicloud-ecs-centos-stream9: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
........
........
Getting error "Failed to get private ip of instance" when using VPC network when associate_public_ip_address
= false
use config as follows:
vpc_id = ...
vswitch_id = ...
associate_public_ip_address = false
Instance is creating with the private IP address assigned:
aliyun ecs DescribeInstances --RegionId cn-shanghai --InstanceIds "['i-uf63g7an1rd3tack5r9q']"
...
"InnerIpAddress": {
"IpAddress": []
},
...
"VpcAttributes": {
"NatIpAddress": "",
"PrivateIpAddress": {
"IpAddress": [
"10.35.243.237"
]
},
"VSwitchId": "vsw-xxx",
"VpcId": "vpc-xxx"
},
"ZoneId": "cn-shanghai-b"
1.0.4, 1.0.5.
Worked before 1.0.4.
==> base_image.alicloud-ecs.base: Prevalidating source region and copied regions...
==> base_image.alicloud-ecs.base: Force delete flag found, skipping prevalidating image name.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepPreValidate'. Press enter to continue.
base_image.alicloud-ecs.base: Found image ID: ubuntu_20_04_x64_20G_alibase_20220824.vhd
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepCheckAlicloudSourceImage'. Press enter to continue.
==> base_image.alicloud-ecs.base: Creating temporary keypair: packer_637c64d4-b76a-755b-3e7a-ecf663a2111c
base_image.alicloud-ecs.base: Saving key for debug purposes: ecs_base.pem
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudKeyPair'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudVPC'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudVSwitch'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepConfigAlicloudSecurityGroup'. Press enter to continue.
==> base_image.alicloud-ecs.base: Creating instance...
base_image.alicloud-ecs.base: Created instance: i-uf63g7an1rd3tack5r9q
==> base_image.alicloud-ecs.base: Pausing after run of step 'stepCreateAlicloudInstance'. Press enter to continue.
==> base_image.alicloud-ecs.base: Failed to get private ip of instance
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepCreateAlicloudInstance'. Press enter to continue.
==> base_image.alicloud-ecs.base: Deleting instance because of cancellation or error...
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudSecurityGroup'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudVSwitch'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudVPC'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepConfigAlicloudKeyPair'. Press enter to continue.
==> base_image.alicloud-ecs.base: Deleting temporary keypair...
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepCheckAlicloudSourceImage'. Press enter to continue.
==> base_image.alicloud-ecs.base: Pausing before cleanup of step 'stepPreValidate'. Press enter to continue.
Build 'base_image.alicloud-ecs.base' finished after 15 minutes 4 seconds.
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
Please add capability to specify resource group for images. This parameter is supported by CreateImage API but not used by AliCloud builder
Taxonomy of resources (e.g. for billing)
I'm trying to create a VM on alicloud and into a particular resource group. I'm using using the provided alicloud-ecs module but it fails with a problem with the resource_group_id. According to the docs this is an acceptable optional field.
https://developer.hashicorp.com/packer/plugins/builders/alicloud
Without the resource_group_id field it runs fine.
I've then added 1.0.4 to my packer file which does get around the resource_group_id problem:
packer {
required_plugins {
alicloud = {
version = "= 1.0.4"
source = "github.com/hashicorp/alicloud"
}
}
}
but it now has ssh issues:
2022/10/04 19:00:26 packer-plugin-alicloud_v1.0.4_x5.0_linux_arm64 plugin: 2022/10/04 19:00:26 [DEBUG] TCP connection to SSH ip/port failed: dial tcp :22: connect: connection refused
same packer file (without the resource_group_id) works fine so the security groups are configured correctly.
Hope someone can help with this. Thanks
"packer.pkr.hcl" packer file (note that I've excluded the ansible provisioner from this issue)
https://gist.github.com/michaelw730/45453a0e775d8d303961d3d542cba580
"aliyun.pkrvars.hcl" vars file (values are from alicloud)
vpc_id = ""
security_group_id = ""
vswitch_id = ""
vpc_cidr_block = "172.16.0.0/24"
resource_group_id = ""
run using
packer build -var "build_number=mw" -var "access_key=$ACCESS_KEY" -var "secret_key=$SECRET_KEY" -var "image_name=debian_10_11_x64_20G_alibase_20220208.vhd" -var-file="aliyun.pkrvars.hcl" "packer.pkr.hcl"
Packer v1.8.0
Ubuntu 20.04 devcontainer on Mac M1
logs here: https://gist.github.com/michaelw730/31b70268e29da4dd5dbd7e8b435b3371
This issue was originally opened by @ghtrke in hashicorp/packer#9138 and has been migrated to this repository. The original issue description is below.
Currently we can only specify the source image id in the builder: source_image
. Could you please add a field so that we can specify the source image name in the builder? Or maybe add a similar feature as source_ami_filter
in AWS builder.
Our requirement is to use packer to first build a base image, and then build app images on top of it. Currently we can only specify the id of the source image as source_image
. However, in our case, the id of the base image is automatically generated from packer result. Besides, the base image is going to have different versions as time goes on. Therefore, it would be great if we could specify the source image name in the builder.
Hi team, when I try to use packer plugin for Alicloud, I found I need some specific RAM permission to call Alicloud APIs. It hasn't been figure out in this doc: https://developer.hashicorp.com/packer/plugins/builders/alicloud. I think it will be clearer after add this part of doc. Here is my PR:
#84
The basic example does not work, trying to build it gives the following error:
==> alicloud-ecs.basic-example: No alicloud image was found matching filters: centos_7_04_64_20G_alibase_201701015.vhd
Other regions, instance types and OSes give the same error, for instance
instance_type = "ecs.t1.small"
region = "eu-central-1"
source_image = "ubuntu_20_04_x64_20G_alibase_20220824.vhd"
This gives the same error as with CentOS previously.
Note these are public images where in the source file step_check_source_image.go at line 38 there is the following:
// Describe markerplace image
describeImagesRequest.ImageOwnerAlias = "marketplace"
Trying to use a marketplace instance id does not work either - same error.
Adding a ram_role_name (required according the documentation, but also see issue #7) does not help either, then the error becomes:
2022/11/10 05:26:12 [INFO] (telemetry) ending alicloud-ecs.basic-example
* refresh Ecs sts token err: Get "http://100.100.100.200/latest/meta-data/ram/security-credentials/usp-test": dial tcp 100.100.100.200:80: i/o timeout
From packer version
macOS Monterey
Prints mostly getting started and nothing about the actual error
While the failed information was reported when building an image using an HCL format configuration, the target image can be successfully built by a JSON format configuration with the same content.
HCL format configuration(named alicloud.pkr.hcl):
packer init alicloud.pkr.hcl
packer build alicloud.pkr.hcl
Plugin version: alicloud v1.0.1
Pakcer version: packer v1.7.10
`packer {
required_plugins{
alicloud = {
version = ">= 1.0.1"
source = "github.com/hashicorp/alicloud"
}
}
}
source "alicloud-ecs" "install-sgx"{
image_name = "sgx-env-installed"
source_image = "ubuntu_18_04_uefi_x64_20G_alibase_20210609.vhd"
ssh_username = "root"
instance_type = "ecs.g7t.large"
io_optimized = true
internet_charge_type = "PayByTraffic"
system_disk_mapping = {
"disk_category" = "cloud_essd"
}
run_tags = {
"Built by" = "Packer"
"Managed by" = "Packer"
}
}
build{
sources = ["sources.alicloud-ecs.install-sgx"]
provisioner "shell"{
script = "./enable-sgx.sh"
}
}`
Operating system: ubuntu 18.04
packer version: ubuntu 18.04
on alicloud.pkr.hcl line 16:
(source code not available)
An argument named "system_disk_mapping" is not expected here. Did you mean to
define a block of type "system_disk_mapping"?
Error: Unsupported argument
on alicloud.pkr.hcl line 16:
(source code not available)
An argument named "system_disk_mapping" is not expected here. Did you mean to
define a block of type "system_disk_mapping"?
2022/02/25 11:48:47 Build debug mode: false
2022/02/25 11:48:47 Force build: false
2022/02/25 11:48:47 On error:
2022/02/25 11:48:47 Waiting on builds to complete...
==> Wait completed after 97 microseconds
==> Wait completed after 97 microseconds
==> Builds finished but no artifacts were created.
==> Builds finished but no artifacts were created.
2022/02/25 11:48:47 [INFO] (telemetry) Finalizing.
2022/02/25 11:48:48 waiting for all plugin processes to complete...
2022/02/25 11:48:48 /root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64: plugin process exited
This issue was originally opened by @mick1627 in hashicorp/packer#10015 and has been migrated to this repository. The original issue description is below.
Be able to add tag to the instance created in alicoud by alicloud-ecs.
Something like the parameter run_tags in amazon-ebs provider.
Once this is done, We will be able to restrict access to ec2 instance based on tag, cf =>
https://www.alibabacloud.com/help/doc-detail/67912.htm?spm=a2c63.p38356.b99.151.3adb6612ZOeMYJ
Exemple:
{
"Statement": [
{
"Action": "ecs:",
"Effect": "Allow",
"Resource": "",
"Condition": {
"StringEquals": {
"ecs:tag/team": "packer"
}
}
},
],
"Version": "1"
}
The idea is to limit ec2 access for some action like DeleteInstances, StopInstance.
Installing k3s with packer will fail, with the error message failed to find cpu cgroup (v2)
.
Need some config vars like:
https://github.com/AliyunContainerService/ack-image-builder/blob/master/scripts/set-cgroupv2.sh
Any relevant use-cases that you see.
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
when run packer build
in an ECS server in which ECSRamRole mode is configured, if the profile
and shared_credentials_file
attributes are configured, the packer build doesn't work.
profile
and shared_credentials_file
attributesFrom 1.8.0
source "alicloud-ecs" "base" {
##image_name = "tio_base_${var.image_name}-${var.ami_build_date}"
image_name = "${var.image_name}-${local.timestamp}"
image_share_account = var.image_share_account
internet_charge_type = var.internet_charge_type
instance_type = var.instance_type
io_optimized = var.io_optimized
profile = "default"
shared_credentials_file = "$HOME/.aliyun/config.json"
region = "cn-shanghai"
source_image = var.latest_image_id
ram_role_name = var.ramfole_for_oss
system_disk_mapping {
disk_size = var.disk_size
disk_category = var.disk_category
}
}
Linux
==> alicloud-ecs.base: Prevalidating source region and copied regions...
==> alicloud-ecs.base: 1 error(s) occurred:
==> alicloud-ecs.base:
==> alicloud-ecs.base: * SDK.ServerError
==> alicloud-ecs.base: ErrorCode: MissingParameter
==> alicloud-ecs.base: Recommend: https://troubleshoot.api.aliyun.com?q=MissingParameter&product=Ecs
==> alicloud-ecs.base: RequestId: CE4AF14B-BE23-5686-AA80-80E6171225B9
==> alicloud-ecs.base: Message: The input parameter "AccessKeyId" that is mandatory for processing this request is not supplied.
Build 'alicloud-ecs.base' errored after 17 milliseconds 187 microseconds: 1 error(s) occurred:
Note: same configurations work well in terraform.
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
AWS EBS builder has a nice feature to add tags to the building instance as below:
run_tags
(map[string]string) - Key/value pair tags to apply to the instance that is that is launched to create the EBS volumes.
It would be super nice to provider the same feature for Alicloud ECS builder.
We can add custom tags attached to the instance that is that is launched to build the image.
`run_tags` (map[string]string) - Key/value pair tags to apply to the instance that is that is launched to create the ECS instance.
Plugin provides source_image
option to find the base image in Alicloud. 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
This issue was originally opened by @Marcus-James-Adams in hashicorp/packer#6952 and has been migrated to this repository. The original issue description is below.
Historically OCI has only allowed the export and import of Linux Images across regions via object storage. However, that now has been changed to allow the copy of windows as well.
It would good if the OCI packer builder could take advantage of this as it would reduce costs for the multi-machine building.
I would envision it working in a similar method to the alicloud image copy.
https://www.packer.io/docs/builders/alicloud-ecs.html#image_copy_regions
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.