Reporting errors in Packer build with AWS-EBS in chroot

21 views
Skip to first unread message

robert....@graebert.com

unread,
Oct 20, 2017, 7:13:15 AM10/20/17
to Packer
Hi,

As part of our packer script, we install some deb packages into an ubuntu instance as well into a chroot environment on that instance. This works well, but we recently had a problem with one dependency not installing well and us not seeing an error from packer. 

Our packer json looks something like this:

     "sudo pip install awscli",
    "sudo /usr/sbin/chroot --userspec=root:root /linoxide add-apt-repository ppa:webupd8team/java -y",
     "sudo /usr/sbin/chroot --userspec=root:root /linoxide apt-get update",
     "sudo /usr/sbin/chroot --userspec=root:root /linoxide apt-get -y install oracle-java8-installer",

There was/is an issue with the java package and the last apt-get install fails due to a 404 error. Packer continues with generating the amis for the other regions.

This is how we call packer build:
packer build -machine-readable -var version=${VERSION} ./packer/xxxx.json | tee build.log
result=$?
if [ ! $result = "0" ]; then
echo "AMI creation failed!"
exit $result
fi

How can bubble up the installation error to jenkins to trigger a build fail?

Many thanks,

Robert

Alvaro Miranda Aguilera

unread,
Oct 20, 2017, 7:22:47 AM10/20/17
to packe...@googlegroups.com
hello

maybe the | tee build.log is causing issues.

if you want error to cross over pipes, you may want to read about pipefail.

ie:

kikitux@alvaro MINGW64 ~
$ true | tee a.log ; echo $?
0

kikitux@alvaro MINGW64 ~
$ false | tee a.log ; echo $?
0

kikitux@alvaro MINGW64 ~
$ set -o pipefail

kikitux@alvaro MINGW64 ~
$ true | tee a.log ; echo $?
0

kikitux@alvaro MINGW64 ~
$ false | tee a.log ; echo $?
1






Virusvrij. www.avast.com

--
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/fcea53c0-2487-4325-908c-dcdef1459980%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Robert Graebert

unread,
Oct 20, 2017, 7:48:47 AM10/20/17
to packe...@googlegroups.com
Hi Alvaro,

thanks for that pointer. We will try that and see if packer was behaving well and the pipe swalled the error.

Robert

You received this message because you are subscribed to a topic in the Google Groups "Packer" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/packer-tool/rwTS8quGyXc/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAHqq0eyTTYuFVjXVxGXecvnAJ8Dkw8KPBUranioWcy1kXyn86w%40mail.gmail.com.

Alvaro Miranda Aguilera

unread,
Oct 20, 2017, 7:59:03 AM10/20/17
to packe...@googlegroups.com
Hello

this:

if [ ! $result = "0" ]; then

will be better as:

if [ ${result} -ne 0 ]; then

Alvaro




For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Robert Graebert

unread,
Oct 20, 2017, 8:12:10 AM10/20/17
to packe...@googlegroups.com
Hi Alvaro,

Testing shows that all is workin well now. Thanks for your help!

Robert

Reply all
Reply to author
Forward
0 new messages