Received Return Code -1 while create AMI from Remote Machine using packer

52 views
Skip to first unread message

Yogesh Sharma

unread,
Apr 16, 2018, 1:08:51 PM4/16/18
to Packer
Hello,

I am trying to create AMI from a remote EC2 machine via python fabric using packer. While I run

run('packer build -var-file=var.json build.json), I get paramiko.ssh_exception.ProxyCommandFailure: Broken pipe. Earlier I though there is some issue with fabric api and opened an issue with fabric here https://github.com/fabric/fabric/issues/1734.

However, except packer all other works flawlessly using fabric run.

On further checking, I found, when AMI is successfully created in host region and copy operations to other region starts, it return -1 after amazon-ebs: Waiting for all copies to complete... and process fails.

This works fine, if we run it locally on EC2 machine where packer is running as stdout. Howeer, it does not work if we execute packer build using ssh ip "command"  or using fabric run.

[10.89.85.229] out: ==> amazon-ebs: Creating the AMI: osgigw-aws-packer-1523896044
[10.89.85.229] out:     amazon-ebs: AMI: ami-3dbed345
[10.89.85.229] out: ==> amazon-ebs: Waiting for AMI to become ready...
[10.89.85.229] out: ==> amazon-ebs: Copying AMI (ami-3dbed345) to other regions...
[10.89.85.229] out:     amazon-ebs: Copying to: us-east-1
[10.89.85.229] out:     amazon-ebs: Copying to: us-east-2
[10.89.85.229] out:     amazon-ebs: Waiting for all copies to complete...

Error:


Fatal error: run() received nonzero return code -1 while executing!

Requested: ./bake.sh
Executed: /bin/bash -l -c "cd /tmp/servicesfabric_apigw_packer/ >/dev/null && ./bake.sh"

Aborting.


Bake.sh:

packer_home="/tmp/packer"
var_file="var.json"
build_file="build.json"

var_json_cmd="-var-file=$var_file"

update_build_cmd="$packer_home build $var_json_cmd $build_file"

$update_build_cmd | tee -a build.log

Please help understanding what could be the issue.

Thanks
Yogesh

Yogesh Sharma

unread,
Apr 16, 2018, 1:41:06 PM4/16/18
to Packer
Last few lines of debug logs:

2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] RPC endpoint: Communicator ended with: 0
2018/04/16 17:29:07 [INFO] 15389 bytes written for 'stdout'
2018/04/16 17:29:07 [INFO] 0 bytes written for 'stderr'
2018/04/16 17:29:07 [INFO] RPC client: Communicator ended with: 0
2018/04/16 17:29:07 [INFO] RPC endpoint: Communicator ended with: 0
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] 15389 bytes written for 'stdout'
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] 0 bytes written for 'stderr'
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] RPC client: Communicator ended with: 0
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 opening new ssh session
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 starting remote command: rm -f /tmp/script_9576.sh
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] RPC endpoint: Communicator ended with: 0
2018/04/16 17:29:07 [INFO] RPC client: Communicator ended with: 0
2018/04/16 17:29:07 [INFO] RPC endpoint: Communicator ended with: 0
2018/04/16 17:29:07 packer: 2018/04/16 17:29:07 [INFO] RPC client: Communicator ended with: 0
2018/04/16 17:29:07 [INFO] (telemetry) ending shell
2018/04/16 17:29:07 ui: ==> amazon-ebs: Stopping the source instance...
2018/04/16 17:29:07 ui:     amazon-ebs: Stopping instance, attempt 1
2018/04/16 17:29:07 ui: ==> amazon-ebs: Waiting for the instance to stop...
2018/04/16 17:29:37 ui: ==> amazon-ebs: Creating the AMI: ami-aws-packer-1523899326
2018/04/16 17:29:38 ui:     amazon-ebs: AMI: ami-16b4d362
2018/04/16 17:29:38 ui: ==> amazon-ebs: Waiting for AMI to become ready...
2018/04/16 17:29:38 packer: 2018/04/16 17:29:38 Waiting for state to become: available
2018/04/16 17:29:38 packer: 2018/04/16 17:29:38 Using 2s as polling delay (change with AWS_POLL_DELAY_SECONDS)
2018/04/16 17:29:38 packer: 2018/04/16 17:29:38 Allowing 300s to complete (change with AWS_TIMEOUT_SECONDS)

2018/04/16 17:32:18 ui: ==> amazon-ebs: Copying AMI (ami-16b4d362) to other regions...
2018/04/16 17:32:18 ui:     amazon-ebs: Copying to: us-east-1
2018/04/16 17:32:18 ui:     amazon-ebs: Copying to: us-east-2
2018/04/16 17:32:18 ui:     amazon-ebs: Waiting for all copies to complete...
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Waiting for state to become: available
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Using 2s as polling delay (change with AWS_POLL_DELAY_SECONDS)
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Allowing 300s to complete (change with AWS_TIMEOUT_SECONDS)
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Waiting for state to become: available
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Using 2s as polling delay (change with AWS_POLL_DELAY_SECONDS)
2018/04/16 17:32:20 packer: 2018/04/16 17:32:20 Allowing 300s to complete (change with AWS_TIMEOUT_SECONDS)

Yogesh Sharma

unread,
Apr 17, 2018, 1:03:31 PM4/17/18
to Packer
this fixed by adjusting AWS_POLL_DELAY_SECONDS and AWS_TIMEOUT_SECONDS to higher value


On Monday, 16 April 2018 22:38:51 UTC+5:30, Yogesh Sharma wrote:

Alvaro Miranda Aguilera

unread,
Apr 18, 2018, 4:43:34 AM4/18/18
to packe...@googlegroups.com
Hello


Can you share what values worked for you ?

Thanks
Alvaro.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/09a5f02f-41d2-46cf-b1ef-e4e641a8a162%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages