CentOS AMI problem with Packer build

83 views
Skip to first unread message

santosh...@acquia.com

unread,
Feb 14, 2019, 3:51:06 AM2/14/19
to Packer
Dear All,
I am trying to create an Amazon base image using the centoOS 7.6 iso from 
https://mirrors.edge.kernel.org/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso
I am able to get the AMI as ami-XXXXX with out any problem.

Now using this output AMI ami-XXXXX, I want to create a another base AMI with some custom configuration, which I want to distribute across my org.

I am getting everytime the following issue 
screen shot 2019-02-13 at 7 16 46 pm


Following in my json

{
"variables": {
"region": "XXXX",
"creator": "{{env `USER`}}",
"ami_name": "centos-7-base-ami-{{timestamp}}",
"source_ami_id": "XXXXX",
"instance_type": "c5.large",
"aws_access_key": "{{env `AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `AWS_SECRET_ACCESS_KEY`}}",
"encrypted": "true"
},
"builders": [
{
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"iam_instance_profile": "packer",
"type": "amazon-ebs",
"region": "XXXX",
"source_ami": "{{user `source_ami_id`}}",
"instance_type": "{{user `instance_type`}}",
"ssh_username": "centos",
"ami_name": "{{user `ami_name`}}",
"ami_description": "CentOS 7 Base AMI",
"associate_public_ip_address": true
}
],
"provisioners": [
{
"type": "shell",
"script": "test.sh",
"expect_disconnect": true
},
{
"type": "shell",
"script": "cleanup.sh"
},
{
"type": "ansible-local",
"playbook_file": "ansible/centOS-7.6-base-ami.yaml",
"role_paths": [
"ansible/roles/"
],
"playbook_dir": "ansible"
}

],
"post-processors": [
{
"type": "manifest",
"output": "manifest.json",
"strip_path": true
}
]
}



Please help me to resolve this error, It is driving me nuts

santosh...@acquia.com

unread,
Feb 14, 2019, 3:59:45 AM2/14/19
to Packer
```
detail logs of 
PACKER_LOG=1 packer build -debug amazon_machine_images/CentOS/7.6-base-ami.json
```

```
2019/02/12 22:29:10 Preparing build: amazon-ebs
amazon-ebs output will be in this color.

2019/02/12 22:29:10 Debug enabled, so waiting for build to finish: amazon-ebs
2019/02/12 22:29:10 Starting build run: amazon-ebs
2019/02/12 22:29:10 Running builder: amazon-ebs
2019/02/12 22:29:10 [INFO] (telemetry) Starting builder amazon-ebs
2019/02/12 22:29:10 packer: 2019/02/12 22:29:10 Found region us-east-1
2019/02/12 22:29:10 packer: 2019/02/12 22:29:10 [INFO] AWS Auth provider used: "SharedConfigCredentials: /Users/rsantoshkumar/.aws/credentials"
2019/02/12 22:29:10 packer: 2019/02/12 22:29:10 [INFO] (aws): No AWS timeout and polling overrides have been set. Packer will default to waiter-specific delays and timeouts. If you would like to customize the length of time between retries and max number of retries you may do so by setting the environment variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS to your desired values.
==> amazon-ebs: Prevalidating AMI Name: centos-7-base-ami-1549990750

2019/02/12 22:29:14 packer: 2019/02/12 22:29:14 Using AMI Filters {
2019/02/12 22:29:14 packer:   ImageIds: ["ami-09ff87be70382f68f"]
2019/02/12 22:29:14 packer: }
==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue.     amazon-ebs: Found Image ID: ami-09ff87be70382f68f
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue. 
==> amazon-ebs: Pausing after run of step 'StepNetworkInfo'. Press enter to continue. 
==> amazon-ebs: Creating temporary keypair: packer_5c62fb5e-c21c-07cc-6549-ef01fc919339
    amazon-ebs: Saving key for debug purposes: ec2_amazon-ebs.pem
==> amazon-ebs: Pausing after run of step 'StepKeyPair'. Press enter to continue. 
==> amazon-ebs: Creating temporary security group for this instance: packer_5c62fb69-2002-0353-2f71-7edf16fa0ecc
2019/02/12 22:29:21 packer: 2019/02/12 22:29:21 [DEBUG] Waiting for temporary security group: sg-0f76a5c4e77ceaae6
2019/02/12 22:29:22 packer: 2019/02/12 22:29:22 [DEBUG] Found security group sg-0f76a5c4e77ceaae6
==> amazon-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> amazon-ebs: Pausing after run of step 'StepSecurityGroup'. Press enter to continue. 
==> amazon-ebs: Pausing after run of step 'StepCleanupVolumes'. Press enter to continue. 
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
    amazon-ebs: Adding tag: "Name": "Packer Builder"
    amazon-ebs: Instance ID: i-0697a87d73b9b0433
==> amazon-ebs: Waiting for instance (i-0697a87d73b9b0433) to become ready...
    amazon-ebs: Public DNS: ec2-3-91-67-118.compute-1.amazonaws.com
    amazon-ebs: Public IP: 3.91.67.118
    amazon-ebs: Private IP: 172.31.27.168
==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue. 
2019/02/12 22:29:46 packer: 2019/02/12 22:29:46 [INFO] Not using winrm communicator, skipping get password...
==> amazon-ebs: Pausing after run of step 'StepGetPassword'. Press enter to continue. 
==> amazon-ebs: Using ssh communicator to connect: 3.91.67.118
2019/02/12 22:29:48 packer: 2019/02/12 22:29:48 [INFO] Waiting for SSH, up to timeout: 5m0s
==> amazon-ebs: Waiting for SSH to become available...
2019/02/12 22:30:03 packer: 2019/02/12 22:30:03 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:30:23 packer: 2019/02/12 22:30:23 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:30:43 packer: 2019/02/12 22:30:43 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:31:03 packer: 2019/02/12 22:31:03 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:31:23 packer: 2019/02/12 22:31:23 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:31:43 packer: 2019/02/12 22:31:43 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:32:03 packer: 2019/02/12 22:32:03 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:32:23 packer: 2019/02/12 22:32:23 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:32:43 packer: 2019/02/12 22:32:43 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:33:03 packer: 2019/02/12 22:33:03 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:33:23 packer: 2019/02/12 22:33:23 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:33:43 packer: 2019/02/12 22:33:43 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:34:03 packer: 2019/02/12 22:34:03 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:34:23 packer: 2019/02/12 22:34:23 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:34:43 packer: 2019/02/12 22:34:43 [DEBUG] TCP connection to SSH ip/port failed: dial tcp 3.91.67.118:22: i/o timeout
2019/02/12 22:34:48 ui error: ==> amazon-ebs: Timeout waiting for SSH.
==> amazon-ebs: Timeout waiting for SSH.
2019/02/12 22:34:48 packer: 2019/02/12 22:34:48 [DEBUG] SSH wait cancelled. Exiting loop.
==> amazon-ebs: Pausing before cleanup of step 'StepGetPassword'. Press enter to continue. 
==> amazon-ebs: Pausing before cleanup of step 'StepRunSourceInstance'. Press enter to continue. 
==> amazon-ebs: Terminating the source AWS instance...


==> amazon-ebs: Pausing before cleanup of step 'StepCleanupVolumes'. Press enter to continue. ==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: Destroying volume (vol-01bc24588a63bb5be)...
==> amazon-ebs: Pausing before cleanup of step 'StepSecurityGroup'. Press enter to continue. ==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Pausing before cleanup of step 'StepKeyPair'. Press enter to continue. 
==> amazon-ebs: Deleting temporary keypair...
==> amazon-ebs: Pausing before cleanup of step 'StepNetworkInfo'. Press enter to continue. 
==> amazon-ebs: Pausing before cleanup of step 'StepSourceAMIInfo'. Press enter to continue. 
==> amazon-ebs: Pausing before cleanup of step 'StepPreValidate'. Press enter to continue. 
2019/02/12 22:50:50 [INFO] (telemetry) ending amazon-ebs
(virtpy3) rsantoshkumar at ALIPL0485 in ~/acquia-ws/is-base-images on master*
$ packer build  amazon_machine_images/CentOS/7.6-base-ami.json 
amazon-ebs output will be in this color.

==> amazon-ebs: Prevalidating AMI Name: centos-7-base-ami-1549992459
    amazon-ebs: Found Image ID: ami-09ff87be70382f68f
==> amazon-ebs: Creating temporary keypair: packer_5c63020b-e96a-0877-5397-e49b13a37ee0
==> amazon-ebs: Creating temporary security group for this instance: packer_5c630210-c3c6-9ce2-dafe-439b3813fc83
==> amazon-ebs: Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group...
==> amazon-ebs: Launching a source AWS instance...
==> amazon-ebs: Adding tags to source instance
    amazon-ebs: Adding tag: "Name": "Packer Builder"
    amazon-ebs: Instance ID: i-06424edb4cdefc0f6
==> amazon-ebs: Waiting for instance (i-06424edb4cdefc0f6) to become ready...
==> amazon-ebs: Using ssh communicator to connect: 54.152.174.226
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Timeout waiting for SSH.
==> amazon-ebs: Terminating the source AWS instance...
==> amazon-ebs: Cleaning up any extra volumes...
==> amazon-ebs: Destroying volume (vol-0ae070b1850908ad6)...
==> amazon-ebs: Deleting temporary security group...
==> amazon-ebs: Deleting temporary keypair...
Build 'amazon-ebs' errored: Timeout waiting for SSH.

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.
``` 

Rickard von Essen

unread,
Feb 14, 2019, 9:57:58 AM2/14/19
to packe...@googlegroups.com
Most likely your AMI built from a ISO doesn't function correctly. Launch one with the cli and successfully connect to it with ssh. If you have problems check the system console log. 

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/30333b98-f595-4c54-939a-9fd993319ab4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Santosh Kumar Ratnala

unread,
Feb 15, 2019, 4:12:05 AM2/15/19
to packe...@googlegroups.com
I have created ec2 instance from the AWS console using the AMI generated from the stage 1.
I am able to ssh it.

Rickard von Essen

unread,
Feb 15, 2019, 4:18:13 AM2/15/19
to packe...@googlegroups.com
Can you verify that you can create a new keypair and launch an instance with it and ssh to it with only that key?

Also when you run packer build add the -on-error=ask argument which will give you some time to verify the network setup and check system console output for errors.

Santosh Kumar Ratnala

unread,
Feb 15, 2019, 4:23:05 AM2/15/19
to packe...@googlegroups.com
Hey Rickard,
I did created a new keypair and launched ec2. Later I was able to ssh with the same key.

I need to run again the packer build with flag you mentioned and will get back to you.
Thank you for responding.

-Santosh

John Roh

unread,
Feb 17, 2019, 5:57:34 PM2/17/19
to packe...@googlegroups.com
I have experienced the similar issue while Windows ec2 as well that winrm fails to validate the credentials. 
If I have provide the hard coded windows credentials it worked. So, either SSH or winrrm, the environmental variable for SSH or WINRm fails to get passed. 
how should we consistently pass environment variable without hard-coded?

John.

Rickard von Essen

unread,
Feb 18, 2019, 2:28:01 PM2/18/19
to packe...@googlegroups.com
John Roh, this thread is about problems an imported CentOS AMI. SSH don't have the problems you describe.

Reply all
Reply to author
Forward
0 new messages