hashicorp / packer

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.
http://www.packer.io
Other
15.11k stars 3.33k forks source link

Winrm Timeout: Packer build for both Linux and Windows based AWS Images #12127

Open itsrahularora1990 opened 1 year ago

itsrahularora1990 commented 1 year ago

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

Overview of the Issue Facing the issue with both AWS Windows and Linux Ubuntu Images. They'are working fine on WinRM and SSH communicator if using public subnet but not for private subnet.

Why it is happenning that packer build stops at winRM and SSH from connecting and how to prevent timeouts from occurring?

A paragraph or two about the issue you're experiencing.

Reproduction Steps Launch the template and attempt to create AWS AMI using packer build command

Plugin and Packer version 1.8.2

Simplified Packer Buildfile

packer {
required_plugins {
amazon = {
version = ">= 1.1.1"
source = "github.com/hashicorp/amazon"
}
}
}

variable "debug" {
type = bool
default = true
}

variable "communicator" {
type = string
default = "ssh"
}

variable "aws_access_key" {
type = string
sensitive = true
default = ""
}

variable "aws_secret_key" {
type = string
sensitive = true
default = ""
}

variable "ssh_username" {
type = string
default = ""
}

variable "pause_before_connecting" {
type = string
default = "2m"
}

source "amazon-ebs" "ubuntu-test" {
communicator = var.communicator
access_key = var.aws_access_key
secret_key = var.aws_secret_key
ssh_username = var.ssh_username
associate_public_ip_address = false
ssh_interface = "private_ip"
ami_name = "ubuntu-test-22.04-hvm-ebs-{{timestamp}}"
pause_before_connecting = var.pause_before_connecting
instance_type = "t2.micro"
region = "us-east-1"
vpc_id = "vpc-##############"
subnet_id = "subnet-################"
source_ami_filter {
filters = {
name = "ubuntu/images/ubuntu-test-22.04-amd64-server-"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
skip_create_ami = "${var.debug}" # true when debugging, false in production
}

build {
name = "ubuntu-test"
sources = [
"source.amazon-ebs.ubuntu-test"
]

provisioner "shell" {
inline = ["apt-get update -y"]
execute_command = "echo 'ubuntu' | sudo -S sh -c '{{ .Vars }} {{ .Path }}'"
}
}

Operating system and Environment details The EC2 is Ubuntu 22-04

Log Fragments and crash.log files

==> ubuntu-test-amazon-ebs.ubuntu-test: Waiting for instance (i-###############) to become ready...
ubuntu-test.amazon-ebs.ubuntu-test Private IP: ##.##.##.##

==> ubuntu-test-amazon-ebs.ubuntu-test: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue. ==> ubuntu-test.amazon-ebs.ubuntu-test: Pausing after run of step 'StepGetPassword'. Press enter to continue.
==> ubuntu-test.amazon-ebs.ubuntu-test: Pausing after run of step 'StepCreateSSMTunnel'. Press enter to continue.
==> ubuntu-test.amazon-ebs.ubuntu-test: Using SSH communicator to connect: ##.##.##.##
==> ubuntu-test.amazon-ebs.ubuntu-test: Waiting for SSH to become available...
==> ubuntu-test.amazon-ebs.ubuntu-test: Timeout waiting for SSH.

Set the env var PACKER_LOG=1 for maximum log detail.

Please suggest the way to connect using 5986 port for WinRM without bootstrap script.

itsrahularora1990 commented 1 year ago

Hi Team,

Is there any update on this please?

itsrahularora1990 commented 1 year ago

Any update?

sundaramsrini commented 1 year ago

Hi Guys,

I am building a windows image in my github actions using Ubuntu22 and am seeing this issue as well. Did anybody manage to find a solution or workaround?

Thanks

cabrennan commented 1 year ago

Seeing this with ubuntu 20.04 also