It sucks when the default values are not documented, this is what you are hitting: https://github.com/mitchellh/packer/blob/master/builder/amazon/chroot/builder.go#L97 I guess there aren't any /etc/resolv.conf in a CoreOS AMI. The simple work around is to add "copy_files": [ "somefile that exist" ] to your template.
Some comments about the workflow: > 1. Run my own ebs-backed instance (with default setting) using public HVM > image of the latest release of CoreOS > 2. Stopped the instance and took AMI image from the stopped instance > 3. Started the instance, logged in, sudo to root, configured > ~/.aws/credentials > 4. Run the packer build Just use the public HVM image of the latest release of CoreOS as the source_ami and don't use access keys when you are running inside AWS, use IAM instance profile/role. This would give you: 1) Start an EC2 instance with the correct instance profile 2) Login to it and run the packer build On Friday, September 16, 2016 at 1:12:53 PM UTC+2, Sergey Esin wrote: > > Thanks for the tip! > > Here's my full template - > https://gist.github.com/sirocode/909f9f90bb7756cf3594d1ea3505d645 > <https://www.google.com/url?q=https%3A%2F%2Fgist.github.com%2Fsirocode%2F909f9f90bb7756cf3594d1ea3505d645&sa=D&sntz=1&usg=AFQjCNHLBmtjNN1xJ_PVY5RVUJNjTVYEUw> > > ("device_type" has been added) > > > I just want to do really simple thing (as a first step with Packer and > amazon-chroot builder) - to get CoreOS of required version with a docker > image downloaded locally. > > "source_ami" mentioned in the template was done the following way: > > 1. Run my own ebs-backed instance (with default setting) using public HVM > image of the latest release of CoreOS > 2. Stopped the instance and took AMI image from the stopped instance > 3. Started the instance, logged in, sudo to root, configured > ~/.aws/credentials > 4. Run the packer build > > > # ./packer build coreos-1122.2.0-hvm-aws-chroot.json > build-aws-hmv-ebs output will be in this color. > > ==> build-aws-hmv-ebs: Prevalidating AMI Name... > ==> build-aws-hmv-ebs: Gathering information about this EC2 instance... > ==> build-aws-hmv-ebs: Inspecting the source AMI... > ==> build-aws-hmv-ebs: Checking the root device on source AMI... > ==> build-aws-hmv-ebs: Creating the root volume... > ==> build-aws-hmv-ebs: Attaching the root volume to /dev/sdg > ==> build-aws-hmv-ebs: Mounting the root device... > ==> build-aws-hmv-ebs: Mounting additional paths within the chroot... > build-aws-hmv-ebs: Mounting: /proc > build-aws-hmv-ebs: Mounting: /sys > build-aws-hmv-ebs: Mounting: /dev > build-aws-hmv-ebs: Mounting: /dev/pts > build-aws-hmv-ebs: Mounting: /proc/sys/fs/binfmt_misc > ==> build-aws-hmv-ebs: Copying files from host to chroot... > build-aws-hmv-ebs: /etc/resolv.conf > ==> build-aws-hmv-ebs: Error copying file: exit status 1 > ==> build-aws-hmv-ebs: nStderr: cp: cannot create regular file > '/mnt/packer-amazon-chroot-volumes/xvdg/etc/resolv.conf': No such file or > directory > ==> build-aws-hmv-ebs: > ==> build-aws-hmv-ebs: Unmounting the root device... > ==> build-aws-hmv-ebs: Detaching EBS volume... > ==> build-aws-hmv-ebs: Deleting the created EBS volume... > Build 'build-aws-hmv-ebs' errored: Error copying file: exit status 1 > nStderr: cp: cannot create regular file > '/mnt/packer-amazon-chroot-volumes/xvdg/etc/resolv.conf': No such file or > directory > > > ==> Some builds didn't complete successfully and had errors: > --> build-aws-hmv-ebs: Error copying file: exit status 1 > nStderr: cp: cannot create regular file > '/mnt/packer-amazon-chroot-volumes/xvdg/etc/resolv.conf': No such file or > directory > > > ==> Builds finished but no artifacts were created. > > > What I am missing? > > > > пятница, 16 сентября 2016 г., 13:50:21 UTC+3 пользователь Rickard von > Essen написал: >> >> If the directory doesn't exist you must create it, see >> https://www.packer.io/docs/provisioners/file.html#destination >> >> If attach your full template plus scripts I can probably point out what >> is wrong. >> >> If you need fast builds I recommend that you add both amazon-ebs and >> amazon-chroot to your template and run with packer build -only=amazon-ebs >> template.json after you have a build that works in the way you expect you >> switch to -only=amazon-chroot. >> >> -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/a9efce53-66b6-44d3-81db-9416d88ad97e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
