Packer: Build 'amazon-ebs' errored

Created on 17 Dec 2015  Â·  5Comments  Â·  Source: hashicorp/packer

Hello,

I'm trying to build the following image and I get an error that I don't know how to debug. Could you please point me to what I'm doing wrong?

I get an Build 'amazon-ebs' errored: Process exited with: 1. Reason was: () error message.

Packer version is v0.8.6.

{
  "builders": [
    {
      "type": "amazon-ebs",
      "region": "eu-west-1",
      "ami_name": "My-CoreOS-835.9.0",
      "source_ami": "ami-c26bcab1",
      "instance_type": "m3.medium",
      "ssh_username": "core"
    }
  ],
  "provisioners": [
    {
      "type": "file",
      "source": "bin/",
      "destination": "/usr/bin"
    }
  ]
}

Running packer with the -debug flag gives me the following output:

$ packer build -debug packer.json                                                                                                                                                                                                                [9:25:08]
Debug mode enabled. Builds will not be parallelized.
amazon-ebs output will be in this color.

==> amazon-ebs: Prevalidating AMI Name...
==> amazon-ebs: Pausing after run of step 'StepPreValidate'. Press enter to continue. 
==> amazon-ebs: Inspecting the source AMI...
==> amazon-ebs: Pausing after run of step 'StepSourceAMIInfo'. Press enter to continue. 
==> amazon-ebs: Creating temporary keypair: packer 56727169-c2b0-7152-c123-cac04f66b41e
    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...
==> amazon-ebs: Authorizing access to port 22 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: Instance ID: i-cbeea840
==> amazon-ebs: Waiting for instance (i-cbeea840) to become ready...
    amazon-ebs: Public DNS: ec2-52-19-93-223.eu-west-1.compute.amazonaws.com
    amazon-ebs: Public IP: 52.19.93.223
    amazon-ebs: Private IP: 172.31.32.234
==> amazon-ebs: Pausing after run of step 'StepRunSourceInstance'. Press enter to continue. 
==> amazon-ebs: Pausing after run of step 'StepGetPassword'. Press enter to continue. 
==> amazon-ebs: Waiting for SSH to become available...
==> amazon-ebs: Connected to SSH!
==> amazon-ebs: Pausing after run of step 'StepConnect'. Press enter to continue. 
==> amazon-ebs: Uploading bin/ => /usr/bin
==> amazon-ebs: Pausing before cleanup of step 'StepConnect'. Press enter to continue. 
==> 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: No AMIs to cleanup
==> 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 'StepSourceAMIInfo'. Press enter to continue. 
==> amazon-ebs: Pausing before cleanup of step 'StepPreValidate'. Press enter to continue. 
Build 'amazon-ebs' errored: Process exited with: 1. Reason was:  ()

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: Process exited with: 1. Reason was:  ()

==> Builds finished but no artifacts were created.

Thanks!

bug provisionefile

Most helpful comment

The trailing slash didn't do it. After some digging I found that /usr is read-only on CoreOS so that was probably what caused the error.

I worked around this by uploading a gzipped folder and extracting it on the destination using the shell provisioner (also used /opt/bin instead which is not write protected).

It's not a huge problem but an error message would be very helpful here. If you think its not worth pursuing I can close this issue.

Just in case anyone is interested this is how the packer template looks like now:

{
  ...
  "provisioners": [
    {
      "type": "file",
      "source": "bin.tar.gz",
      "destination": "/tmp/bin.tar.gz"
    },
    {
      "type": "shell",
      "inline": [
        "sudo mkdir -p /opt",
        "sudo tar -xvf /tmp/bin.tar.gz -C /opt",
        "sudo chmod +x -R /opt/bin"
      ]
    }
  ]
}

All 5 comments

Skip the --debug flag and run with env PACKER_LOG=1.

e.g.

PACKER_LOG=1 packer build packer.json

Gist the log. See http://packer.io/docs/other/debugging.html

@rickard-von-essen thanks for the quick reply. Here's the log.

https://gist.github.com/alexkappa/bcc11ab14995e9ff6517

The scp fails, did you try to add a slash to the destination?
On Dec 17, 2015 10:57 AM, "Alex Kalyvitis" [email protected] wrote:

@rickard-von-essen https://github.com/rickard-von-essen thanks for the
quick reply. Here's the log.

https://gist.github.com/alexkappa/bcc11ab14995e9ff6517

—
Reply to this email directly or view it on GitHub
https://github.com/mitchellh/packer/issues/3003#issuecomment-165404369.

The trailing slash didn't do it. After some digging I found that /usr is read-only on CoreOS so that was probably what caused the error.

I worked around this by uploading a gzipped folder and extracting it on the destination using the shell provisioner (also used /opt/bin instead which is not write protected).

It's not a huge problem but an error message would be very helpful here. If you think its not worth pursuing I can close this issue.

Just in case anyone is interested this is how the packer template looks like now:

{
  ...
  "provisioners": [
    {
      "type": "file",
      "source": "bin.tar.gz",
      "destination": "/tmp/bin.tar.gz"
    },
    {
      "type": "shell",
      "inline": [
        "sudo mkdir -p /opt",
        "sudo tar -xvf /tmp/bin.tar.gz -C /opt",
        "sudo chmod +x -R /opt/bin"
      ]
    }
  ]
}

Thanks for the report, I think we can improve the error feedback here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mwhooker picture mwhooker  Â·  3Comments

Tensho picture Tensho  Â·  3Comments

Nikoos picture Nikoos  Â·  3Comments

paulcdejean picture paulcdejean  Â·  3Comments

sourav82 picture sourav82  Â·  3Comments