Code Monkey home page Code Monkey logo

packer-plugin-alicloud's Issues

Support for multiple security groups with security_group_ids

Community Note

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.

Description

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.

Use Case(s)

Attach multiple, pre-existing security groups to an instance created by packer instead of just one.

Potential configuration

{
  "security_group_ids": [
    "sg-...",
    "sg-...",
    "sg-..."
  ]
}

Potential References

RamRoleArn mode is not supported when profile is used

Overview of the Issue

when 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.

Reproduction Steps

  1. create a ram user in aliyun
  2. create a profile for the ram user by aliyun cli tool with RamRoleArn mode
  3. create a packer script to use the profile attributes
  4. run the packer build

Plugin and Packer Version

  1. Packer v1.8.3
  2. packer-plugin-alicloud v1.0.4

Simplified Packer Buildfile

source "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
  }
}

Operating system and Environment details

ubuntu 18.04

Log Fragments and crash.log files

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.

Null Vaule for Image Tag in Packer 1.4.1 in AliCloud will cause error

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

still have ssh connection issue when building image using centos stream 9 base image with the latest packer/packer-plugin-alicloud

This issue was originally opened by @Forrest2023github in hashicorp/packer#12896 and has been migrated to this repository. The original issue description is below.


Community Note

  • 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 other comments that do not add relevant new information or questions, 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

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

Overview of the Issue

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

Packer version

1.10.2

Packer alicloud plugin version

1.1.1

Simplified Packer Template

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

Log Fragments and crash.log files

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

Failed to get private ip of instance

Overview of the Issue

Getting error "Failed to get private ip of instance" when using VPC network when associate_public_ip_address = false

Reproduction Steps

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"

Plugin and Packer version

1.0.4, 1.0.5.
Worked before 1.0.4.

Log Fragments and crash.log files

==> 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 add resource_group parameter (already available in CreateImage API)

Community Note

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.

Description

Please add capability to specify resource group for images. This parameter is supported by CreateImage API but not used by AliCloud builder

Use Case(s)

Taxonomy of resources (e.g. for billing)

SSH issue with 1.0.4

Overview of the Issue

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

Reproduction Steps

"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 version

Packer v1.8.0

Operating system and Environment details

Ubuntu 20.04 devcontainer on Mac M1

Log Fragments and crash.log files

logs here: https://gist.github.com/michaelw730/31b70268e29da4dd5dbd7e8b435b3371

Add source image name support in AliCloud builder

This issue was originally opened by @ghtrke in hashicorp/packer#9138 and has been migrated to this repository. The original issue description is below.


Feature Description

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.

Use Case(s)

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.

The basic example does not work.

Overview of the Issue

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

Reproduction Steps

  • Download the basic example and save as 'basic.example'
  • Set secret_key and access_key
  • Run 'packer build basic.example'

From packer version

  • 1.8.4
  • plugin: 1.0.4

Simplified Packer Buildfile

See https://github.com/hashicorp/packer-plugin-alicloud/blob/main/docs/builders/alicloud-ecs.mdx#basic-example

Operating system and Environment details

macOS Monterey

Log Fragments and crash.log files

Prints mostly getting started and nothing about the actual error

An argument name "system_disk_mapping" is not expected here

Overview of the Issue

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.

Reproduction Steps

HCL format configuration(named alicloud.pkr.hcl):

packer init alicloud.pkr.hcl

packer build alicloud.pkr.hcl

Plugin and Packer version

Plugin version: alicloud v1.0.1

Pakcer version: packer v1.7.10

Simplified Packer Buildfile

`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 and Environment details

Operating system: ubuntu 18.04

packer version: ubuntu 18.04

Log Fragments and crash.log files

Log 2022/02/25 11:48:47 [INFO] Packer version: 1.7.10 [go1.17.6 linux amd64] 2022/02/25 11:48:47 [TRACE] discovering plugins in /usr/bin 2022/02/25 11:48:47 [TRACE] discovering plugins in /root/.config/packer/plugins 2022/02/25 11:48:47 [TRACE] discovering plugins in . 2022/02/25 11:48:47 [INFO] PACKER_CONFIG env var not set; checking the default config file path 2022/02/25 11:48:47 [INFO] PACKER_CONFIG env var set; attempting to open config file: /root/.packerconfig 2022/02/25 11:48:47 [WARN] Config file doesn't exist: /root/.packerconfig 2022/02/25 11:48:47 [INFO] Setting cache directory: /root/.cache/packer 2022/02/25 11:48:47 [TRACE] listing potential installations for "github.com/hashicorp/alicloud" that match ">= 1.0.1". plugingetter.ListInstallationsOptions{FromFolders:[]stri ng{"/usr/bin/packer", ".", "/root/.config/packer/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linu x", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00015a100)}}}} 2022/02/25 11:48:47 [TRACE] Found the following "github.com/hashicorp/alicloud" installations: [{/root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicl oud_v1.0.1_x5.0_linux_amd64 v1.0.1}] 2022/02/25 11:48:47 [INFO] found external [ecs] builders from alicloud plugin 2022/02/25 11:48:47 [INFO] found external [import] post-processors from alicloud plugin 2022/02/25 11:48:47 [TRACE] Starting external plugin /root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 start builder ec s 2022/02/25 11:48:47 Starting plugin: /root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 []string{"/root/.config/packer/p lugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64", "start", "builder", "ecs"} 2022/02/25 11:48:47 Waiting for RPC address for: /root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 2022/02/25 11:48:47 Received unix RPC address for /root/.config/packer/plugins/github.com/hashicorp/alicloud/packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64: addr is /tmp/packe r-plugin570028700 2022/02/25 11:48:47 packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 plugin: 2022/02/25 11:48:47 Plugin address: unix /tmp/packer-plugin570028700 2022/02/25 11:48:47 packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 plugin: 2022/02/25 11:48:47 Waiting for connection... 2022/02/25 11:48:47 packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 plugin: 2022/02/25 11:48:47 Serving a plugin connection... 2022/02/25 11:48:47 packer-plugin-alicloud_v1.0.1_x5.0_linux_amd64 plugin: 2022/02/25 11:48:47 [TRACE] starting builder ecs

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

add run_tags for alicloud-ecs Builder to tag created ecs instance

This issue was originally opened by @mick1627 in hashicorp/packer#10015 and has been migrated to this repository. The original issue description is below.


Description

Be able to add tag to the instance created in alicoud by alicloud-ecs.
Something like the parameter run_tags in amazon-ebs provider.

Use Case(s)

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.

EcsRamRole mode is not supported when profile is used

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

Overview of the Issue

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.

Reproduction Steps

  1. create a linux ECS server in aliyun with RamRole configured
  2. Run aliyun configure to use ECSRamRole mode
  3. create a packer script to use the profile and shared_credentials_file attributes
  4. run the packer build

Plugin and Packer version

From 1.8.0

Simplified Packer Buildfile

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

Operating system and Environment details

Linux

Log Fragments and crash.log files

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

run_tags configuration

Community Note

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.

Description

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.

Use Case(s)

We can add custom tags attached to the instance that is that is launched to build the image.

Potential configuration

`run_tags` (map[string]string) - Key/value pair tags to apply to the instance that is that is launched to create the ECS instance.

Potential References

https://www.packer.io/docs/builders/amazon/ebs

Feature Request: Oracle OCI support of image copy to regions

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

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.